package com.changhai.diabetes.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.commons.io.FileUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.CellRangeAddress;

import com.changhai.diabetes.model.Bear;
import com.changhai.diabetes.model.BearForExport;
import com.changhai.diabetes.model.ConcurrentResultForExport;
import com.changhai.diabetes.model.Drug;
import com.changhai.diabetes.model.DrugTreatment;
import com.changhai.diabetes.model.DrugTreatmentForExport;
import com.changhai.diabetes.model.Family;
import com.changhai.diabetes.model.FamilyForExport;
import com.changhai.diabetes.model.InterGroupUser;
import com.changhai.diabetes.model.InterPatientGroup;
import com.changhai.diabetes.model.InterPatientUser;
import com.changhai.diabetes.model.LabPhysical;
import com.changhai.diabetes.model.LabPhysicalForExport;
import com.changhai.diabetes.model.LabSugar;
import com.changhai.diabetes.model.LabSugarForExport;
import com.changhai.diabetes.model.NutritionSuifang;
import com.changhai.diabetes.model.NutritionSuifangForExport;
import com.changhai.diabetes.model.NutritionSurvey;
import com.changhai.diabetes.model.NutritionSurveyForExport;
import com.changhai.diabetes.model.NutritionTreatment;
import com.changhai.diabetes.model.NutritionTreatmentForExport;
import com.changhai.diabetes.model.OpertResultMsg;
import com.changhai.diabetes.model.Patient;
import com.changhai.diabetes.model.PatientForExport;
import com.changhai.diabetes.model.Personal;
import com.changhai.diabetes.model.PersonalForExport;
import com.changhai.diabetes.model.PhysicalSurveyResult;
import com.changhai.diabetes.model.PhysicalSurveyResultForExport;
import com.changhai.diabetes.model.QualitySurveyResult;
import com.changhai.diabetes.model.QualitySurveyResultForExport;
import com.changhai.diabetes.model.ResearchGroup;
import com.changhai.diabetes.model.ResearchGroupForExport;
import com.changhai.diabetes.model.SportsSuifang;
import com.changhai.diabetes.model.SportsSuifangForExport;
import com.changhai.diabetes.model.SportsSurvey;
import com.changhai.diabetes.model.SportsSurveyForExport;
import com.changhai.diabetes.model.SportsTreatment;
import com.changhai.diabetes.model.SportsTreatmentForExport;
import com.changhai.diabetes.model.SymptomsSurvey;
import com.changhai.diabetes.model.SymptomsSurveyResult;
import com.changhai.diabetes.model.SymptomsSurveyResultForExport;
import com.changhai.diabetes.model.TableForPatient;
import com.changhai.diabetes.model.User;
import com.changhai.diabetes.service.DataService;
import com.changhai.diabetes.service.NutritionService;
import com.changhai.diabetes.service.SurveyService;

/**
 * 数据导入导出
 * 
 * 
 */
public class DataAction extends BaseAction {

	private static final long serialVersionUID = 4392936553263004630L;
	private OpertResultMsg opertMsg;
	private int extype;
	private int imtype;
	private String filename;
	private DataService dataService;
	private NutritionService nutritionService;
	private SurveyService surveyService;
	private File file;

	public String execute() throws Exception {
		return super.execute();
	}

	public String exData() {
		return "input";
	}

	public String imData() {
		return "input";
	}

	public String exportData() {
		String info = filename.substring(filename.lastIndexOf("/") + 1,
				filename.lastIndexOf(".") - 1);
		try {
			if (extype == 1) {
				hospitalToExcel(filename);
			} else if (extype == 2) {
				groupToExcel(filename);
			} else if (extype == 3) {
				patientListToExcel(filename);
			} else if (extype == 4) {
				patientToExcel(filename);
			} else if (extype == 5) {
				personalToExcel(filename);
			} else if (extype == 6) {
				bearToExcel(filename);
			} else if (extype == 7) {
				familyToExcel(filename);
			} else if (extype == 8) {
				// 伴随并发症情况
				concurrentToExcel(filename);
			} else if (extype == 9) {
				labPhysicalToExcel(filename);
			} else if (extype == 10) {
				// 营养调查
				nutritionSurveyToExcel(filename);
			} else if (extype == 11) {
				// 营养治疗
				nutritionTreatmentToExcel(filename);
			} else if (extype == 12) {
				// 营养随访
				nutritionSuifangToExcel(filename);
			} else if (extype == 13) {
				// 运动调查
				sportsSurveyToExcel(filename);
			} else if (extype == 14) {
				// 运动治疗
				sportsTreatmentToExcel(filename);
			} else if (extype == 15) {
				// 运动随访
				sportsSuifangToExcel(filename);
			} else if (extype == 16) {
				// 药物治疗
				drugTreatmentToExcel(filename);
			} else if (extype == 17) {
				// 体质调查
				physicalSurveyResultToExcel(filename);
			} else if (extype == 18) {
				// 生存质量
				qualitySurveyResultToExcel(filename);
			} else if (extype == 19) {
				// 症候
				symptomsSurveyResultToExcel(filename);
			} else if (extype == 20) {
				// 症候判别结果
				symptomsResultToExcel(filename);
			} else if (extype == 21) {
				// 血糖指标
				bloodSugarIndexToExcel(filename);
			}else if (extype == 22) {
				// 血脂指标
				symptomsResultToExcel(filename);
			}else if (extype == 23) {
				// 胰岛功能
				symptomsResultToExcel(filename);
			}else if (extype == 24) {
				// 血常规
				symptomsResultToExcel(filename);
			}else if (extype == 25) {
				// 肝肾功能
				symptomsResultToExcel(filename);
			}else if (extype == 26) {
				// 尿液检查
				symptomsResultToExcel(filename);
			}else if (extype == 27) {
				// 其他指标
				symptomsResultToExcel(filename);
			}else if (extype == 28) {
				// 检验随访
				symptomsResultToExcel(filename);
			}
			opertMsg = new OpertResultMsg(Long.valueOf(0), info + "导出成功!");
		} catch (Exception e) {
			opertMsg = new OpertResultMsg(Long.valueOf(1), info + "导出失败!");
		}
		return "input";
	}

	public String importData() {
		System.out.println(1);
		try {
			switch (imtype) {
			case 1:
				excelToHospital(filename);
				break;
			case 2:
				excelToGroup(filename);
				break;
			case 3:
				excelToPatientList(filename);
				break;
			case 4:
				excelToPatient(filename);
				break;
			case 5:
				excelToPersonal(filename);
				break;
			case 6:
				excelToBear(filename);
				break;
			case 7:
				excelToFamily(filename);
				break;
			case 8:
				// 伴随并发症情况
				excelToConcurrent(filename);
				break;
			case 9:
				excelToLabPhysical(filename);
				break;
			case 10:
				// 营养调查
				excelToNutritionSurvey(filename);
				break;
			case 11:
				// 营养治疗
				excelToNutritionTreatment(filename);
				break;
			case 12:
				// 营养随访
				excelToNutritionSuifang(filename);
				break;
			case 13:
				// 运动调查
				excelToSportsSurvey(filename);
				break;
			case 14:
				// 运动治疗
				excelToSportsTreatment(filename);
				break;
			case 15:
				// 运动随访
				excelToSportsSuifang(filename);
				break;
			case 16:
				// 药物治疗
				excelToDrugTreatment(filename);
				break;
			case 17:
				// 体质调查
				excelToPhysicalSurveyResult(filename);
				break;
			case 18:
				// 生存质量
				excelToQualitySurveyResult(filename);
				break;
			case 19:
				// 症候
				excelToSymptomsSurveyResult(filename);
				break;
			case 20:
				// 症候判别结果
				excelToSymptomsResult(filename);
				break;
			case 21:
				// 血糖指标
				symptomsResultToExcel(filename);
				break;
			case 22:
				// 血脂指标
				symptomsResultToExcel(filename);
				break;
			case 23:
				// 胰岛功能
				symptomsResultToExcel(filename);
				break;
			case 24:
				// 血常规
				symptomsResultToExcel(filename);
				break;
			case 25:
				// 肝肾功能
				symptomsResultToExcel(filename);
				break;
			case 26:
				// 尿液检查
				symptomsResultToExcel(filename);
				break;
			case 27:
				// 其他指标
				symptomsResultToExcel(filename);
				break;
			case 28:
				// 检验随访
				symptomsResultToExcel(filename);
				break;
			default:
				break;
			}

			opertMsg = new OpertResultMsg(Long.valueOf(0), "数据导入成功!");
		} catch (Exception e) {
			opertMsg = new OpertResultMsg(Long.valueOf(1), "数据导入失败!");
		}
		return "input";
	}

	public void hospitalToExcel(String filename) throws Exception {
		FileOutputStream fileOut = null;
		List<User> userList = new ArrayList<User>();
		List<ResearchGroup> groupList = new ArrayList<ResearchGroup>();
		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("医院信息管理");
			HSSFRow row = sheet.createRow((short) 0);

			row.createCell(0).setCellValue("单位名称");
			row.createCell(1).setCellValue("单位编号");
			row.createCell(2).setCellValue("单位地址");
			row.createCell(3).setCellValue("联系人姓名");
			row.createCell(4).setCellValue("联系电话");
			row.createCell(5).setCellValue("临床组别1");
			row.createCell(6).setCellValue("临床组别2");
			row.createCell(7).setCellValue("开始时间");
			row.createCell(8).setCellValue("总人数");
			row.createCell(9).setCellValue("随访周期");
			row.createCell(10).setCellValue("状态");

			userList = dataService.getUserList();
			if (userList != null && userList.size() > 0) {
				int k = 1;
				for (int i = 0; i < userList.size(); i++) {
					row = sheet.createRow((short) k);
					row.createCell(0).setCellValue(userList.get(i).getDanwei());
					row.createCell(1).setCellValue(userList.get(i).getUserid());
					row.createCell(2)
							.setCellValue(userList.get(i).getAddress());
					row.createCell(3).setCellValue(
							userList.get(i).getRelateperson());
					row.createCell(4).setCellValue(
							userList.get(i).getPhonenumber());
					groupList = dataService.getGroupListByUserId(userList
							.get(i).getUserid());
					if (groupList != null && groupList.size() > 0) {
						row.createCell(5).setCellValue(
								groupList.get(0).getGroupbh());
						row.createCell(6).setCellValue(
								groupList.get(0).getGroupname());
						row.createCell(7).setCellValue(
								groupList.get(0).getStarttime());
						row.createCell(8).setCellValue(
								groupList.get(0).getPatientcount());

						if (groupList.get(0).getTimelong() != null
								&& groupList.get(0).getTimetype() != null) {
							if (groupList.get(0).getTimetype() == 0) {
								row.createCell(9).setCellValue(
										groupList.get(0).getTimelong() + "日");
							} else if (groupList.get(0).getTimetype() == 1) {
								row.createCell(9).setCellValue(
										groupList.get(0).getTimelong() + "个月");
							} else if (groupList.get(0).getTimetype() == 2) {
								row.createCell(9).setCellValue(
										groupList.get(0).getTimelong() + "年");
							}
						} else {
							row.createCell(9).setCellValue("0");
						}

						if (groupList.get(0).getGroupstatus() == 0) {
							row.createCell(10).setCellValue("进行中");
						} else if (groupList.get(0).getGroupstatus() == 1) {
							row.createCell(10).setCellValue("已结束");
						}

						if (groupList.size() > 1) {
							for (int m = 1; m < groupList.size(); m++) {
								row = sheet.createRow((short) ++k);
								row.createCell(5).setCellValue(
										groupList.get(m).getGroupbh());
								row.createCell(6).setCellValue(
										groupList.get(m).getGroupname());
								row.createCell(7).setCellValue(
										groupList.get(m).getStarttime());
								row.createCell(8).setCellValue(
										groupList.get(m).getPatientcount());

								if (groupList.get(m).getTimelong() != null
										&& groupList.get(m).getTimetype() != null) {
									if (groupList.get(m).getTimetype() == 0) {
										row.createCell(9).setCellValue(
												groupList.get(m).getTimelong()
														+ "日");
									} else if (groupList.get(m).getTimetype() == 1) {
										row.createCell(9).setCellValue(
												groupList.get(m).getTimelong()
														+ "个月");
									} else if (groupList.get(m).getTimetype() == 2) {
										row.createCell(9).setCellValue(
												groupList.get(m).getTimelong()
														+ "年");
									}
								} else {
									row.createCell(9).setCellValue("0");
								}

								if (groupList.get(m).getGroupstatus() == 0) {
									row.createCell(10).setCellValue("进行中");
								} else if (groupList.get(m).getGroupstatus() == 1) {
									row.createCell(10).setCellValue("已结束");
								}
							}
						}
					}
					k++;
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} finally {
			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void groupToExcel(String filename) throws Exception {
		FileOutputStream fileOut = null;
		List<ResearchGroupForExport> groupList = new ArrayList<ResearchGroupForExport>();
		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("临床分组设定");
			HSSFRow row = sheet.createRow((short) 0);

			row.createCell(0).setCellValue("所属医院");
			row.createCell(1).setCellValue("临床组别1");
			row.createCell(2).setCellValue("临床组别2");
			row.createCell(3).setCellValue("干预因素");
			row.createCell(4).setCellValue("随访周期");
			row.createCell(5).setCellValue("调查内容");

			groupList = dataService.getAllGroupList();
			int k = 1;
			if (groupList != null && groupList.size() > 0) {
				for (int i = 0; i < groupList.size(); i++) {
					if (groupList.get(i).getParentgroup() == 0) {
						row = sheet.createRow((short) k);
						row.createCell(0).setCellValue(
								groupList.get(i).getDanwei());
						row.createCell(1).setCellValue(
								groupList.get(i).getGroupbh());
						row.createCell(2).setCellValue(
								groupList.get(i).getGroupname());
						String ganyu = "";
						List<ResearchGroup> list = dataService
								.getGanyuGroupListById(groupList.get(i)
										.getResearchgroupid());
						if (list != null && list.size() > 0) {
							for (ResearchGroup g : list) {
								if (g.getGroupbh() != null
										&& g.getGroupname() != null) {
									ganyu += g.getGroupbh() + g.getGroupname()
											+ ",";
								}
							}
							ganyu = ganyu.substring(0, ganyu.length() - 1);
						}
						row.createCell(3).setCellValue(ganyu);

						if (groupList.get(i).getTimelong() != null
								&& groupList.get(i).getTimetype() != null) {
							if (groupList.get(i).getTimetype() == 0) {
								row.createCell(4).setCellValue(
										groupList.get(i).getTimelong() + "日");
							} else if (groupList.get(i).getTimetype() == 1) {
								row.createCell(4).setCellValue(
										groupList.get(i).getTimelong() + "个月");
							} else if (groupList.get(i).getTimetype() == 2) {
								row.createCell(4).setCellValue(
										groupList.get(i).getTimelong() + "年");
							}
						} else {
							row.createCell(4).setCellValue("0");
						}

						String con = "";
						if (groupList.get(i).getContent() != null
								&& !groupList.get(i).getContent().equals("")) {
							List<String> res = dataService
									.getSurveyContentByIds(groupList.get(i)
											.getContent());
							if (res != null) {
								con = res.toString();
							}
						}
						row.createCell(5).setCellValue(con);
						k++;
					}
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} finally {
			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void patientListToExcel(String filename) throws Exception {
		FileOutputStream fileOut = null;
		List<PatientForExport> patientList = new ArrayList<PatientForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("病人列表");
			HSSFRow row = sheet.createRow((short) 0);

			row.createCell(0).setCellValue("所属医院");
			row.createCell(1).setCellValue("临床组别1");
			row.createCell(2).setCellValue("临床组别2");
			row.createCell(3).setCellValue("编号");
			row.createCell(4).setCellValue("姓名");
			row.createCell(5).setCellValue("家庭住址");
			row.createCell(6).setCellValue("联系电话");
			row.createCell(7).setCellValue("开始时间");
			row.createCell(8).setCellValue("随访时间");
			row.createCell(9).setCellValue("状态");

			patientList = dataService.getPatientListForExport();
			if (patientList != null && patientList.size() > 0) {
				for (int i = 0; i < patientList.size(); i++) {
					row = sheet.createRow((short) i + 1);
					row.createCell(0).setCellValue(
							patientList.get(i).getDanwei());

					if (patientList.get(i).getGroupBh() != null
							&& patientList.get(i).getGroupName() != null) {
						row.createCell(1).setCellValue(
								patientList.get(i).getGroupBh());
						row.createCell(2).setCellValue(
								patientList.get(i).getGroupName());
					} else {
						row.createCell(1).setCellValue("");
						row.createCell(2).setCellValue("");
					}

					row.createCell(3).setCellValue(
							patientList.get(i).getPatientid());
					row.createCell(4).setCellValue(
							patientList.get(i).getPatientname());
					if (patientList.get(i).getAddress() != null) {
						row.createCell(5).setCellValue(
								patientList.get(i).getAddress());
					} else {
						row.createCell(5).setCellValue("");
					}
					row.createCell(6).setCellValue(
							patientList.get(i).getTelephone());

					row.createCell(7).setCellValue(
							patientList.get(i).getStarttime());
					row.createCell(8).setCellValue(
							patientList.get(i).getFollowtime());

					Integer status = patientList.get(i).getPatientstatus();
					if (status != null) {
						switch (status) {
						case 0:
							row.createCell(9).setCellValue("进行中");
							break;
						case 1:
							row.createCell(9).setCellValue("死亡");
							break;
						case 2:
							row.createCell(9).setCellValue("失访");
							break;
						case 3:
							row.createCell(9).setCellValue("结束");
							break;
						case 4:
							row.createCell(9).setCellValue("退出");
							break;
						default:
							row.createCell(9).setCellValue("");
							break;
						}
					} else {
						row.createCell(9).setCellValue("");
					}
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} finally {
			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void patientToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<PatientForExport> patientList = new ArrayList<PatientForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("基本信息");
			HSSFRow row = sheet.createRow((short) 0);

			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			row.createCell(2).setCellValue("工作性质");
			row.createCell(3).setCellValue("工作单位");
			row.createCell(4).setCellValue("家庭住址");
			row.createCell(5).setCellValue("邮编");
			row.createCell(6).setCellValue("联系电话");
			row.createCell(7).setCellValue("联系人姓名");
			row.createCell(8).setCellValue("联系人电话");
			row.createCell(9).setCellValue("临床组别编号");
			row.createCell(10).setCellValue("临床组别");
			row.createCell(11).setCellValue("状态");
			row.createCell(12).setCellValue("结局");

			patientList = dataService.getPatientListForExport();
			if (patientList != null && patientList.size() > 0) {
				for (int i = 0; i < patientList.size(); i++) {
					row = sheet.createRow((short) i + 1);
					// 0
					row.createCell(0).setCellValue(
							patientList.get(i).getPatientid());
					// 1
					row.createCell(1).setCellValue(
							patientList.get(i).getPatientname());
					// 2
					int worktype1 = patientList.get(i).getWorktype1();
					int worktype2 = patientList.get(i).getWorktype2();
					StringBuilder worktype = new StringBuilder("");
					switch (worktype1) {
					case 0: {
						worktype.append("非军人-");
						switch (worktype2) {
						case 0:
							worktype.append("公务员");
							break;
						case 1:
							worktype.append("工厂企业");
							break;
						case 2:
							worktype.append("事业单位");
							break;
						case 3:
							worktype.append("服务业");
							break;
						case 4:
							worktype.append("商业");
							break;
						case 5:
							worktype.append("医教研");
							break;
						case 6:
							worktype.append("农林牧渔劳动者");
							break;
						case 7:
							worktype.append("自由职业者");
							break;
						case 8:
							worktype.append("其他劳动者");
							break;
						default:
							break;
						}
						break;
					}
					case 1: {
						worktype.append("军人-");
						switch (worktype2) {
						case 0:
							worktype.append("陆军");
							break;
						case 1:
							worktype.append("海军");
							break;
						case 2:
							worktype.append("空军");
							break;
						case 3:
							worktype.append("二炮");
							break;
						case 4:
							worktype.append("其他");
							break;
						default:
							break;
						}
						break;
					}
					default:
						break;
					}
					row.createCell(2).setCellValue(worktype.toString());
					// 3
					row.createCell(3).setCellValue(
							patientList.get(i).getWorkplace());
					// 4
					row.createCell(4).setCellValue(
							patientList.get(i).getAddress());
					// 5
					row.createCell(5).setCellValue(
							patientList.get(i).getZipcode());
					// 6
					row.createCell(6).setCellValue(
							patientList.get(i).getTelephone());
					// 7
					row.createCell(7).setCellValue(
							patientList.get(i).getRelate());
					// 8
					row.createCell(8).setCellValue(
							patientList.get(i).getRelatephone());
					// 9
					row.createCell(9).setCellValue(
							patientList.get(i).getResearchGroupId());
					// 10
					if (patientList.get(i).getGroupBh() != null
							&& patientList.get(i).getGroupName() != null) {
						row.createCell(10).setCellValue(
								patientList.get(i).getGroupBh()
										+ patientList.get(i).getGroupName());
					} else {
						row.createCell(10).setCellValue("");
					}
					// 11
					Integer status = patientList.get(i).getPatientstatus();
					if (status != null) {
						switch (status) {
						case 0:
							row.createCell(11).setCellValue("进行中");
							break;
						case 1:
							row.createCell(11).setCellValue("死亡");
							row.createCell(12).setCellValue("死亡");
							break;
						case 2:
							row.createCell(11).setCellValue("失访");
							row.createCell(12).setCellValue("失访");
							break;
						case 3:
							row.createCell(11).setCellValue("结束");
							break;
						case 4:
							row.createCell(11).setCellValue("退出");
							break;
						default:
							row.createCell(11).setCellValue("");
							break;
						}
					} else {
						row.createCell(11).setCellValue("");
					}
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void personalToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<PersonalForExport> personalList = new ArrayList<PersonalForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("个人史");
			HSSFRow row = sheet.createRow((short) 0);
			HSSFRow row2 = sheet.createRow((short) 1);
			sheet.addMergedRegion(new CellRangeAddress(0, 0, 14, 25));

			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			row.createCell(2).setCellValue("学历");
			row.createCell(3).setCellValue("婚姻状况");
			row.createCell(4).setCellValue("家庭人均月收入");
			row.createCell(5).setCellValue("出生地");
			row.createCell(6).setCellValue("出生体重");
			row.createCell(7).setCellValue("长期居留地");
			row.createCell(8).setCellValue("药物过敏史");
			row.createCell(9).setCellValue("过敏药物");
			row.createCell(10).setCellValue("食物过敏史");
			row.createCell(11).setCellValue("过敏食物");
			row.createCell(12).setCellValue("饮酒");
			row.createCell(13).setCellValue("开始饮酒时间");
			row.createCell(14).setCellValue("饮酒种类及数量");
			row2.createCell(14).setCellValue("白酒");
			row2.createCell(15).setCellValue("次/周");
			row2.createCell(16).setCellValue("两/次");
			row2.createCell(17).setCellValue("黄酒");
			row2.createCell(18).setCellValue("次/周");
			row2.createCell(19).setCellValue("两/次");
			row2.createCell(20).setCellValue("红酒");
			row2.createCell(21).setCellValue("次/周");
			row2.createCell(22).setCellValue("两/次");
			row2.createCell(23).setCellValue("啤酒");
			row2.createCell(24).setCellValue("次/周");
			row2.createCell(25).setCellValue("两/次");
			row.createCell(26).setCellValue("戒酒");
			row.createCell(27).setCellValue("戒酒时间(年)");
			row.createCell(28).setCellValue("吸烟");
			row.createCell(29).setCellValue("每日吸烟支数");
			row.createCell(30).setCellValue("吸烟年数");
			row.createCell(31).setCellValue("吸烟指数");
			row.createCell(32).setCellValue("戒烟");
			row.createCell(33).setCellValue("戒烟时间（年）");
			row.createCell(34).setCellValue("周围环境中经常有人吸烟");

			String[] str4 = { "", "已婚", "未婚", "再婚", "离异", "丧偶" };
			personalList = dataService.getPersonalListForExport();
			if (personalList != null && personalList.size() > 0) {
				for (int i = 0; i < personalList.size(); i++) {
					PersonalForExport personal = personalList.get(i);

					row = sheet.createRow((short) i + 2);
					// 0
					row.createCell(0).setCellValue(personal.getPatientid());
					// 1
					row.createCell(1).setCellValue(personal.getPatientName());
					// 2
					int education = personal.getEducation();
					switch (education) {
					case 0:
						row.createCell(2).setCellValue("大专及以上");
						break;
					case 1:
						row.createCell(2).setCellValue("中专");
						break;
					case 2:
						row.createCell(2).setCellValue("中学");
						break;
					case 3:
						row.createCell(2).setCellValue("小学");
						break;
					case 4:
						row.createCell(2).setCellValue("文盲");
						break;
					case 5:
						row.createCell(2).setCellValue("不详");
						break;
					default:
						break;
					}
					// 3
					int marriage = personal.getMarriage();
					row.createCell(3).setCellValue(str4[marriage]);
					// 4
					int temp = personal.getIncome();
					switch (temp) {
					case 0:
						row.createCell(4).setCellValue("＜500元");
						break;
					case 1:
						row.createCell(4).setCellValue("500－1000元");
						break;
					case 2:
						row.createCell(4).setCellValue("1000－2000元");
						break;
					case 3:
						row.createCell(4).setCellValue("2000－5000元");
						break;
					case 4:
						row.createCell(4).setCellValue("5000－10000");
						break;
					case 5:
						row.createCell(4).setCellValue("＞10000");
						break;
					case 6:
						row.createCell(4).setCellValue("不详");
						break;
					default:
						break;
					}
					// 5
					row.createCell(5).setCellValue(personal.getBirthplace());
					// 6
					Double dbl = personal.getBirthweight();
					row.createCell(6).setCellValue(
							dbl == null ? "" : dbl.toString());
					// 7
					row.createCell(7).setCellValue(personal.getLiveplace());
					// 8
					temp = personal.getDrugallergy();
					switch (temp) {
					case 0:
						row.createCell(8).setCellValue("无");
						break;
					case 1:
						row.createCell(8).setCellValue("有");
						break;
					case 2:
						row.createCell(8).setCellValue("不详");
						break;
					default:
						break;
					}
					// 9
					row.createCell(9).setCellValue(personal.getDrug());
					// 10
					temp = personal.getFoodallergy();
					switch (temp) {
					case 0:
						row.createCell(10).setCellValue("无");
						break;
					case 1:
						row.createCell(10).setCellValue("有");
						break;
					case 2:
						row.createCell(10).setCellValue("不详");
						break;
					default:
						break;
					}
					// 11
					row.createCell(11).setCellValue(personal.getFood());
					// 12
					int drink = personal.getDrink();
					if (0 == drink) {
						row.createCell(12).setCellValue("否");
					} else {
						row.createCell(12).setCellValue("是");
					}
					// 13
					Integer itg = personal.getDrinkage();
					row.createCell(6).setCellValue(
							itg == null ? "" : itg.toString());
					// 14
					String[] drinktype = personal.getDrinktype().split(",");
					String[] drinkfrequency = personal.getDrinkfrequency()
							.split(",");
					String[] drinkamount = personal.getDrinkamount().split(",");
					for (int j = 0; j < 4; j++) {
						if (drinktype[j].equals("1")) {
							row.createCell(14 + j * 3).setCellValue("是");
						} else {
							row.createCell(14 + j * 3).setCellValue("否");
						}
						row.createCell(14 + j * 3 + 1).setCellValue(
								drinkfrequency[j]);
						row.createCell(14 + j * 3 + 2).setCellValue(
								drinkamount[j]);
					}
					// 26
					temp = personal.getStopdrink();
					if (0 == temp) {
						row.createCell(26).setCellValue("否");
					} else {
						row.createCell(26).setCellValue("是");
						// 27
						row.createCell(27).setCellValue(
								personal.getStopdrinktime()==null?"":personal.getStopdrinktime().toString());
					}

					// 28
					temp = personal.getSmoke();
					if (0 == temp) {
						row.createCell(28).setCellValue("否");
					} else {
						row.createCell(28).setCellValue("是");
						// 29
						row.createCell(29).setCellValue(
								personal.getSmokeamount()==null?"":personal.getSmokeamount().toString());
						// 30
						row.createCell(30).setCellValue(
								personal.getSmokelast() + "年");
						// 31
						row.createCell(31)
								.setCellValue(personal.getSmokeexpo()==null?"":personal.getSmokeexpo().toString());
					}

					// 32
					temp = personal.getStopdrink();
					if (0 == temp) {
						row.createCell(32).setCellValue("否");
					} else {
						row.createCell(32).setCellValue("是");
						// 33
						row.createCell(33).setCellValue(
								personal.getStopsmokelast()==null?"":personal.getStopsmokelast().toString());
					}

					// 34
					temp = personal.getAroundsmoke();
					if (0 == temp) {
						row.createCell(34).setCellValue("否");
					} else {
						row.createCell(34).setCellValue("是");
					}
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void bearToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<BearForExport> list = new ArrayList<BearForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("生育史");
			HSSFRow row = sheet.createRow((short) 0);

			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			row.createCell(2).setCellValue("正常分娩");
			row.createCell(3).setCellValue("胎数");
			row.createCell(4).setCellValue("妊娠高血压史");
			row.createCell(5).setCellValue("胎数");
			row.createCell(6).setCellValue("妊娠高血糖史");
			row.createCell(7).setCellValue("胎数");
			row.createCell(8).setCellValue("宫外孕史");
			row.createCell(9).setCellValue("胎数");
			row.createCell(10).setCellValue("生育巨大胎儿史");
			row.createCell(11).setCellValue("胎数");
			row.createCell(12).setCellValue("自然流产史");
			row.createCell(13).setCellValue("胎数");

			list = dataService.getBearListForExport();
			if (list != null && list.size() > 0) {
				for (int i = 0; i < list.size(); i++) {
					row = sheet.createRow((short) i + 1);
					// 0
					row.createCell(0).setCellValue(list.get(i).getPatientid());
					// 1
					row.createCell(1)
							.setCellValue(list.get(i).getPatientName());
					// 2
					String[] str1 = { "无", "有", "不详" };
					int sel1 = list.get(i).getFenmian();
					row.createCell(2).setCellValue(str1[sel1]);
					if (1 == sel1) {
						// 3
						row.createCell(3)
								.setCellValue(list.get(i).getFmcount());
					}
					// 4
					sel1 = list.get(i).getRensheny();
					row.createCell(4).setCellValue(str1[sel1]);
					if (1 == sel1) {
						// 5
						row.createCell(5).setCellValue(
								list.get(i).getRsycount());
					}
					// 6
					sel1 = list.get(i).getRenshent();
					row.createCell(6).setCellValue(str1[sel1]);
					if (1 == sel1) {
						// 7
						row.createCell(7).setCellValue(
								list.get(i).getRstcount());
					}
					// 8
					sel1 = list.get(i).getGongwai();
					row.createCell(8).setCellValue(str1[sel1]);
					if (1 == sel1) {
						// 9
						row.createCell(9)
								.setCellValue(list.get(i).getGwcount());
					}
					// 10
					sel1 = list.get(i).getTaier();
					row.createCell(10).setCellValue(str1[sel1]);
					if (1 == sel1) {
						// 11
						row.createCell(11).setCellValue(
								list.get(i).getTaiercount());
					}
					// 12
					sel1 = list.get(i).getLiuchan();
					row.createCell(12).setCellValue(str1[sel1]);
					if (1 == sel1) {
						// 13
						row.createCell(13).setCellValue(
								list.get(i).getLccount());
					}
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void familyToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<FamilyForExport> list = new ArrayList<FamilyForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("家族史");
			HSSFRow row = sheet.createRow((short) 0);

			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			row.createCell(2).setCellValue("糖尿病病史");
			row.createCell(3).setCellValue("类型");
			row.createCell(4).setCellValue("关系");
			row.createCell(5).setCellValue("血脂异常疾病病史");
			row.createCell(6).setCellValue("病名");
			row.createCell(7).setCellValue("关系");
			row.createCell(8).setCellValue("高血压病史");
			row.createCell(9).setCellValue("关系");
			row.createCell(10).setCellValue("脑血管病史");
			row.createCell(11).setCellValue("关系");
			row.createCell(12).setCellValue("冠心病、心梗病史");
			row.createCell(13).setCellValue("关系");
			row.createCell(14).setCellValue("其他遗传性疾病病史");
			row.createCell(15).setCellValue("病名");
			row.createCell(16).setCellValue("关系");

			list = dataService.getFamilyListForExport();
			int rowcount = 1;
			if (list != null && list.size() > 0) {
				for (int i = 0; i < list.size(); i++) {
					row = sheet.createRow(rowcount++);
					// 0
					row.createCell(0).setCellValue(list.get(i).getPatientid());
					// 1
					row.createCell(1)
							.setCellValue(list.get(i).getPatientName());
					// 2
					String[] str1 = { "无", "有", "不详" };
					String[] str2 = { "1型", "2型", "妊娠糖尿病", "其他" };
					String[] str3 = { "祖父母", "外祖父母", "父亲", "母亲", "兄弟、姐妹", "子女" };
					Integer sel1 = list.get(i).getDiabetes();
					row.createCell(2).setCellValue(str1[sel1]);
					if (1 == sel1) {
						// 3
						ArrayList<String> dlist = new ArrayList<String>();
						ArrayList<String> rlist = new ArrayList<String>();
						Integer i2 = list.get(i).getDiabetes1();
						if (i2 != null) {
							dlist.add(str2[i2]);
							rlist.add(list.get(i).getDiabetesrelate1());
						}
						i2 = list.get(i).getDiabetes2();
						if (i2 != null) {
							dlist.add(str2[i2]);
							rlist.add(list.get(i).getDiabetesrelate2());
						}
						i2 = list.get(i).getDiabetes3();
						if (i2 != null) {
							dlist.add(str2[i2]);
							rlist.add(list.get(i).getDiabetesrelate3());
						}
						i2 = list.get(i).getDiabetes4();
						if (i2 != null) {
							dlist.add(str2[i2]);
							rlist.add(list.get(i).getDiabetesrelate4());
						}

						for (int j = 0; j < dlist.size(); j++) {
							String dstr = dlist.get(j);
							HSSFRow nrow = sheet.createRow(rowcount - 1 + j);
							// 3
							nrow.createCell(3).setCellValue(dstr);
							// 4
							nrow.createCell(4).setCellValue(rlist.get(j));
						}
						if (dlist.size() > 1) {
							rowcount += dlist.size() - 1;
						}
					}

					// 5
					sel1 = list.get(i).getLipids();
					if (sel1 != null && sel1 < 3 && sel1 > -1) {
						row.createCell(5).setCellValue(str1[sel1]);
						if (1 == sel1) {
							// 6
							row.createCell(6).setCellValue(
									list.get(i).getLipidsname());
							// 7
							row.createCell(7).setCellValue(
									list.get(i).getLipidsrelate());
						}
					}
					// 8
					sel1 = list.get(i).getHighblood();
					if (sel1 != null && sel1 < 3 && sel1 > -1) {
						row.createCell(8).setCellValue(str1[sel1]);
						if (1 == sel1) {
							// 9
							row.createCell(9).setCellValue(
									list.get(i).getHighbloodrelate());
						}
					}
					// 10
					sel1 = list.get(i).getNaoxueguan();
					if (sel1 != null && sel1 < 3 && sel1 > -1) {
						row.createCell(10).setCellValue(str1[sel1]);
						if (1 == sel1) {
							// 11
							row.createCell(11).setCellValue(
									list.get(i).getNxgrelate());
						}
					}
					// 12
					sel1 = list.get(i).getGuanxinbin();
					if (sel1 != null && sel1 < 3 && sel1 > -1) {
						row.createCell(12).setCellValue(str1[sel1]);
						if (1 == sel1) {
							// 13
							row.createCell(13).setCellValue(
									list.get(i).getGxbrelate());
						}
					}
					// 14
					sel1 = list.get(i).getGenetic();
					if (sel1 != null && sel1 < 3 && sel1 > -1) {
						row.createCell(14).setCellValue(str1[sel1]);
						if (1 == sel1) {
							// 15
							row.createCell(15).setCellValue(
									list.get(i).getGeneticname());
							// 16
							row.createCell(16).setCellValue(
									list.get(i).getGeneticrelate());
						}
					}
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void labPhysicalToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<LabPhysicalForExport> list = new ArrayList<LabPhysicalForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("体格测试");
			HSSFRow row0 = sheet.createRow((short) 0);
			HSSFRow row = sheet.createRow((short) 1);
			sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 11));
			row0.createCell(0).setCellValue("第一次");

			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			row.createCell(2).setCellValue("身高");
			row.createCell(3).setCellValue("体重");
			row.createCell(4).setCellValue("体质指数");
			row.createCell(5).setCellValue("体型");
			row.createCell(6).setCellValue("腰围");
			row.createCell(7).setCellValue("臀围");
			row.createCell(8).setCellValue("腰臀比");
			row.createCell(9).setCellValue("足背动脉搏动");
			row.createCell(10).setCellValue("胫后动脉搏动");

			list = dataService.getLabPhysicalListForExport();
			if (list != null && list.size() > 0) {
				for (int i = 0; i < list.size(); i++) {
					row = sheet.createRow((short) i + 2);
					// 0
					row.createCell(0).setCellValue(list.get(i).getPatientid());
					// 1
					row.createCell(1)
							.setCellValue(list.get(i).getPatientName());
					// 2
					Double dbl = list.get(i).getHeight();
					if (dbl != null) {
						row.createCell(2).setCellValue(dbl);
					}

					// 3
					dbl = list.get(i).getWeight();
					if (dbl != null) {
						row.createCell(3).setCellValue(dbl);
					}
					// 4
					dbl = list.get(i).getBmi();
					if (dbl != null) {
						row.createCell(4).setCellValue(dbl);
					}
					// 5
					String[] str1 = { "消瘦", "正常", "超重", "肥胖" };
					Integer sel1 = list.get(i).getStyle();
					if (sel1 != null && sel1 < 4 && sel1 > -1) {
						row.createCell(5).setCellValue(str1[sel1]);
					}

					// 6
					dbl = list.get(i).getWaistline();
					if (dbl != null) {
						row.createCell(6).setCellValue(dbl);
					}
					// 7
					dbl = list.get(i).getHip();
					if (dbl != null) {
						row.createCell(7).setCellValue(dbl);
					}
					// 8
					dbl = list.get(i).getWhr();
					if (dbl != null) {
						row.createCell(8).setCellValue(dbl);
					}
					// 9
					sel1 = list.get(i).getArterya();
					if (dbl != null) {
						row.createCell(9).setCellValue(dbl);
					}
					// 10
					sel1 = list.get(i).getArteryb();
					if (dbl != null) {
						row.createCell(10).setCellValue(dbl);
					}
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void nutritionSurveyToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<NutritionSurveyForExport> list = new ArrayList<NutritionSurveyForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("营养调查");
			HSSFRow row0 = sheet.createRow((short) 0);
			HSSFRow row = sheet.createRow((short) 1);
			sheet.addMergedRegion(new CellRangeAddress(0, 0, 2, 8));
			row0.createCell(2).setCellValue("第一次");

			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			row.createCell(2).setCellValue("谷薯类");
			row.createCell(3).setCellValue("蔬菜类");
			row.createCell(4).setCellValue("鱼肉蛋类");
			row.createCell(5).setCellValue("豆类");
			row.createCell(6).setCellValue("乳类");
			row.createCell(7).setCellValue("水果类");
			row.createCell(8).setCellValue("油脂类");

			list = dataService.getNutritionSurveyListForExport();
			if (list != null && list.size() > 0) {
				for (int i = 0; i < list.size(); i++) {
					row = sheet.createRow((short) i + 2);
					// 0
					row.createCell(0).setCellValue(list.get(i).getPatientid());
					// 1
					row.createCell(1)
							.setCellValue(list.get(i).getPatientName());
					// 2
					Double dbl1 = list.get(i).getZhushitotal();
					if (dbl1 != null) {
						row.createCell(2).setCellValue(dbl1);
					}
					// 3
					dbl1 = list.get(i).getShucaitotal();
					if (dbl1 != null) {
						row.createCell(3).setCellValue(dbl1);
					}
					// 4
					dbl1 = list.get(i).getYuroutotal();
					if (dbl1 != null) {
						row.createCell(4).setCellValue(dbl1);
					}
					// 5
					dbl1 = list.get(i).getDoutotal();
					if (dbl1 != null) {
						row.createCell(5).setCellValue(dbl1);
					}
					// 6
					dbl1 = list.get(i).getRutotal();
					if (dbl1 != null) {
						row.createCell(6).setCellValue(dbl1);
					}
					// 7
					dbl1 = list.get(i).getShuiguototal();
					if (dbl1 != null) {
						row.createCell(7).setCellValue(dbl1);
					}
					// 8
					dbl1 = list.get(i).getYouzhitotal();
					if (dbl1 != null) {
						row.createCell(8).setCellValue(dbl1);
					}
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void nutritionSuifangToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<NutritionSuifangForExport> list = new ArrayList<NutritionSuifangForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("营养随访");
			HSSFRow row0 = sheet.createRow((short) 0);
			HSSFRow row = sheet.createRow((short) 1);
			sheet.addMergedRegion(new CellRangeAddress(0, 0, 2, 9));
			row0.createCell(2).setCellValue("第一次");

			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			row.createCell(2).setCellValue("是否按推荐饮食");
			row.createCell(3).setCellValue("谷薯类");
			row.createCell(4).setCellValue("蔬菜类");
			row.createCell(5).setCellValue("鱼肉蛋类");
			row.createCell(6).setCellValue("豆类");
			row.createCell(7).setCellValue("乳类");
			row.createCell(8).setCellValue("水果类");
			row.createCell(9).setCellValue("油脂类");

			list = dataService.getNutritionSuifangListForExport();
			if (list != null && list.size() > 0) {
				for (int i = 0; i < list.size(); i++) {
					row = sheet.createRow((short) i + 2);
					// 0
					row.createCell(0).setCellValue(list.get(i).getPatientid());
					// 1
					row.createCell(1)
							.setCellValue(list.get(i).getPatientName());
					// 2
					Integer itg1 = list.get(i).getRecommend();
					if (itg1 != null) {
						if (0 == itg1) {
							row.createCell(2).setCellValue("否");
						} else if (1 == itg1) {
							row.createCell(2).setCellValue("是");
						}
					}

					// 3
					Double dbl1 = list.get(i).getZhushitotal();
					if (dbl1 != null) {
						row.createCell(3).setCellValue(dbl1);
					}
					// 4
					dbl1 = list.get(i).getShucaitotal();
					if (dbl1 != null) {
						row.createCell(4).setCellValue(dbl1);
					}
					// 5
					dbl1 = list.get(i).getYuroutotal();
					if (dbl1 != null) {
						row.createCell(5).setCellValue(dbl1);
					}
					// 6
					dbl1 = list.get(i).getDoutotal();
					if (dbl1 != null) {
						row.createCell(6).setCellValue(dbl1);
					}
					// 7
					dbl1 = list.get(i).getRutotal();
					if (dbl1 != null) {
						row.createCell(7).setCellValue(dbl1);
					}
					// 8
					dbl1 = list.get(i).getShuiguototal();
					if (dbl1 != null) {
						row.createCell(8).setCellValue(dbl1);
					}
					// 9
					dbl1 = list.get(i).getYouzhitotal();
					if (dbl1 != null) {
						row.createCell(9).setCellValue(dbl1);
					}
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void nutritionTreatmentToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<NutritionTreatmentForExport> list = new ArrayList<NutritionTreatmentForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("营养治疗");
			HSSFRow row0 = sheet.createRow((short) 0);
			HSSFRow row = sheet.createRow((short) 1);
			sheet.addMergedRegion(new CellRangeAddress(0, 0, 2, 8));
			row0.createCell(2).setCellValue("第一次");

			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			row.createCell(2).setCellValue("开始时间");
			row.createCell(3).setCellValue("结束时间");
			row.createCell(4).setCellValue("吃水果");
			row.createCell(5).setCellValue("限制主食摄入");
			row.createCell(6).setCellValue("能量供给量");
			row.createCell(7).setCellValue("能量水平");
			row.createCell(8).setCellValue("推荐饮食");

			list = dataService.getNutritionTreatmentListForExport();
			if (list != null && list.size() > 0) {
				for (int i = 0; i < list.size(); i++) {
					row = sheet.createRow((short) i + 2);
					// 0
					row.createCell(0).setCellValue(list.get(i).getPatientid());
					// 1
					row.createCell(1)
							.setCellValue(list.get(i).getPatientName());
					// 2
					row.createCell(2).setCellValue(list.get(i).getStarttime());
					// 3
					row.createCell(3).setCellValue(list.get(i).getEndtime());
					// 4
					Integer itg1 = list.get(i).getSuitfruit();
					if (itg1 != null) {
						if (0 == itg1) {
							row.createCell(4).setCellValue("否");
						} else if (1 == itg1) {
							row.createCell(4).setCellValue("是");
						}
					}
					// 5
					itg1 = list.get(i).getLimitmeal();
					if (itg1 != null) {
						if (0 == itg1) {
							row.createCell(5).setCellValue("否");
						} else if (1 == itg1) {
							row.createCell(5).setCellValue("是");
						}
					}
					// 6
					Double dbl1 = list.get(i).getEnergyamount();
					if (dbl1 != null) {
						row.createCell(6).setCellValue(dbl1);
					}
					// 7
					dbl1 = list.get(i).getEnergylevel();
					if (dbl1 != null) {
						row.createCell(7).setCellValue(dbl1);
					}
					// 8
					Integer recommend = 0;
					String[] str1 = { "限制碳水化合物饮食", "低碳水化合物饮食", "一般饮食" };
					Map<String, Object> nt = nutritionService
							.searchTreatByPatientId(list.get(i).getPatientid());
					if (nt != null) {
						// nutriTreat = (NutritionTreatment) map.get("treat");
						recommend = (Integer) nt.get("recommend");
					}
					if (recommend != null && recommend > 0 && recommend < 4) {
						row.createCell(8).setCellValue(str1[recommend - 1]);
					}
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void sportsSurveyToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<SportsSurveyForExport> list = new ArrayList<SportsSurveyForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("运动调查");
			HSSFRow row0 = sheet.createRow((short) 0);
			HSSFRow row = sheet.createRow((short) 1);
			sheet.addMergedRegion(new CellRangeAddress(0, 0, 2, 12));
			row0.createCell(2).setCellValue("第一次");

			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			row.createCell(2).setCellValue("劳动强度");
			row.createCell(3).setCellValue("规律运动");
			row.createCell(4).setCellValue("不愿运动原因");
			row.createCell(5).setCellValue("运动形式");
			row.createCell(6).setCellValue("运动方式");
			row.createCell(7).setCellValue("运动时间");
			row.createCell(8).setCellValue("运动次数");
			row.createCell(9).setCellValue("运动持续时间");
			row.createCell(10).setCellValue("运动前进餐");
			row.createCell(11).setCellValue("服用降糖药或胰岛素");
			row.createCell(12).setCellValue("运动受伤");

			list = dataService.getSportsSurveyListForExport();
			if (list != null && list.size() > 0) {
				for (int i = 0; i < list.size(); i++) {
					row = sheet.createRow((short) i + 2);
					// 0
					row.createCell(0).setCellValue(list.get(i).getPatientid());
					// 1
					row.createCell(1)
							.setCellValue(list.get(i).getPatientName());
					// 2
					Integer itg1 = list.get(i).getWorksports();
					String[] str1 = { "卧床休息", "轻度活动", "中度活动", "重度活动" };
					if (itg1 != null && itg1 > -1 && itg1 < 4) {
						row.createCell(2).setCellValue(str1[itg1]);
					}
					// 3
					itg1 = list.get(i).getIsregular();
					if (itg1 != null) {
						if (0 == itg1) {
							row.createCell(3).setCellValue("是");
						} else if (1 == itg1) {
							row.createCell(3).setCellValue("否");
						}
					}
					// 4
					String[] str2 = { "没兴趣。", "没时间。", "惰性，没有毅力坚持。",
							"体力工作，没有必要参加。", "缺乏场地设施。", "身体不适，不宜参加。",
							"运动后身体不适（头晕、心慌、胸闷、胃痛、低血糖反应）。" };
					String[] reasons = list.get(i).getNoreason().split(",");
					String str = "";
					for (int j = 0; j < reasons.length; j++) {
						int temp = Integer.parseInt(reasons[j].trim());
						str += str2[temp - 1];
					}
					row.createCell(4).setCellValue(str);
					// 5
					String[] str3 = { "轻度活动（种花、家务、步行等)",
							"中度活动（慢跑、羽毛球、健身操、健身气功、跳舞等)", "重度活动（举杠铃、游泳、跳绳等）" };
					itg1 = list.get(i).getSportstype();
					if (itg1 != null && itg1 > -1 && itg1 < 3) {
						row.createCell(5).setCellValue(str3[itg1]);
					}
					// 6 ???运动方式 数据库没有相关数据
					String[] str13 = { "个人运动", "集体运动" };
					itg1 = list.get(i).getSportsway();
					if (itg1 != null && itg1 > -1 && itg1 < 3) {
						row.createCell(6).setCellValue(str13[itg1]);
					}

					// 7
					String[] str4 = { "早上", "上午", "下午", "晚饭后" };
					itg1 = list.get(i).getSportstime();
					if (itg1 != null && itg1 > -1 && itg1 < 4) {
						row.createCell(7).setCellValue(str4[itg1]);
					}
					// 8
					String[] str5 = { "1~2次", "3~4次", "5~7次" };
					itg1 = list.get(i).getSportscount();
					if (itg1 != null && itg1 > -1 && itg1 < 3) {
						row.createCell(8).setCellValue(str5[itg1]);
					}
					// 9
					String[] str6 = { "30min", "30-60min", "60-90min", "90min" };
					itg1 = list.get(i).getSportslast();
					if (itg1 != null && itg1 > -1 && itg1 < 4) {
						row.createCell(9).setCellValue(str6[itg1]);
					}
					// 10
					itg1 = list.get(i).getTakemeal();
					if (itg1 != null) {
						if (0 == itg1) {
							row.createCell(10).setCellValue("是");
						} else if (1 == itg1) {
							row.createCell(10).setCellValue("否");
						}
					}
					// 11
					itg1 = list.get(i).getTakedrug();
					if (itg1 != null) {
						if (0 == itg1) {
							row.createCell(11).setCellValue("是");
						} else if (1 == itg1) {
							row.createCell(11).setCellValue("否");
						}
					}
					// 12
					itg1 = list.get(i).getIshurt();
					if (itg1 != null) {
						if (0 == itg1) {
							row.createCell(12).setCellValue("是");
						} else if (1 == itg1) {
							row.createCell(12).setCellValue("否");
						}
					}
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void sportsSuifangToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<SportsSuifangForExport> list = new ArrayList<SportsSuifangForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("运动随访");
			HSSFRow row0 = sheet.createRow((short) 0);
			HSSFRow row = sheet.createRow((short) 1);
			sheet.addMergedRegion(new CellRangeAddress(0, 0, 2, 16));
			row0.createCell(2).setCellValue("第一次");

			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			row.createCell(2).setCellValue("坚持运动处方");
			row.createCell(3).setCellValue("选择其他形式");
			row.createCell(4).setCellValue("运动形式");
			row.createCell(5).setCellValue("运动频率(次/周)");
			row.createCell(6).setCellValue("运动时间(分钟/次)");
			row.createCell(7).setCellValue("清晨起床心律");
			row.createCell(8).setCellValue("安静状态心率");
			row.createCell(9).setCellValue("运动后即刻心率");
			row.createCell(10).setCellValue("运动前安静状态呼吸");
			row.createCell(11).setCellValue("运动后即刻呼吸");
			row.createCell(12).setCellValue("运动前血糖");
			row.createCell(13).setCellValue("运动后即刻血糖");
			row.createCell(14).setCellValue("运动后自我感觉疲劳程度");
			row.createCell(15).setCellValue("运动后低血糖反应");
			row.createCell(16).setCellValue("次数");

			list = dataService.getSportsSuifangListForExport();
			if (list != null && list.size() > 0) {
				for (int i = 0; i < list.size(); i++) {
					row = sheet.createRow((short) i + 2);
					// 0
					row.createCell(0).setCellValue(list.get(i).getPatientid());
					// 1
					row.createCell(1)
							.setCellValue(list.get(i).getPatientName());
					// 2
					Integer itg1 = list.get(i).getIsfollow();
					if (itg1 != null) {
						if (1 == itg1) {
							row.createCell(2).setCellValue("是");
						} else if (2 == itg1) {
							row.createCell(2).setCellValue("否");
						}
					}

					// 3
					itg1 = list.get(i).getOthertype();
					if (itg1 != null) {
						if (1 == itg1) {
							row.createCell(3).setCellValue("是");
						} else if (2 == itg1) {
							row.createCell(3).setCellValue("否");
						}
					}
					// 4
					row.createCell(4).setCellValue(list.get(i).getSportstype());
					// 5
					itg1 = list.get(i).getSportsfreq();
					if (itg1 != null) {
						row.createCell(5).setCellValue(itg1);
					}
					// 6
					Double dbl1 = list.get(i).getSportstime();
					if (dbl1 != null) {
						row.createCell(6).setCellValue(dbl1);
					}
					// 7
					itg1 = list.get(i).getMorningrate();
					if (itg1 != null) {
						row.createCell(7).setCellValue(itg1);
					}
					// 8
					itg1 = list.get(i).getRatea();
					if (itg1 != null) {
						row.createCell(8).setCellValue(itg1);
					}
					// 9
					itg1 = list.get(i).getRateb();
					if (itg1 != null) {
						row.createCell(9).setCellValue(itg1);
					}
					// 10
					itg1 = list.get(i).getHuxia();
					if (itg1 != null) {
						row.createCell(10).setCellValue(itg1);
					}
					// 11
					itg1 = list.get(i).getHuxib();
					if (itg1 != null) {
						row.createCell(11).setCellValue(itg1);
					}
					// 12
					dbl1 = list.get(i).getXuetanga();
					if (dbl1 != null) {
						row.createCell(12).setCellValue(dbl1);
					}
					// 13
					dbl1 = list.get(i).getXuetangb();
					if (dbl1 != null) {
						row.createCell(13).setCellValue(dbl1);
					}
					// 14
					String[] str1 = { "没有感觉", "非常轻松", "比较轻松", "轻松", "稍微有点累",
							"有点累", "比较累", "非常累", "因累而有不适感", "因累身体不适并难以忍受",
							"累到极点" };
					itg1 = list.get(i).getFeel();
					if (itg1 != null && itg1 > -1 && itg1 < 11) {
						row.createCell(14).setCellValue(str1[itg1]);
					}
					// 15
					itg1 = list.get(i).getLowsugar();
					if (itg1 != null) {
						if (1 == itg1) {
							row.createCell(15).setCellValue("否");
						} else if (2 == itg1) {
							row.createCell(15).setCellValue("是");
						}
					}
					// 16
					itg1 = list.get(i).getLowcount();
					if (itg1 != null) {
						row.createCell(16).setCellValue(itg1);
					}
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void sportsTreatmentToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<SportsTreatmentForExport> list = new ArrayList<SportsTreatmentForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("运动随访");
			HSSFRow row0 = sheet.createRow((short) 0);
			HSSFRow row = sheet.createRow((short) 1);
			sheet.addMergedRegion(new CellRangeAddress(0, 0, 2, 7));
			row0.createCell(2).setCellValue("第一次");

			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			row.createCell(2).setCellValue("开始时间");
			row.createCell(3).setCellValue("结束时间");
			row.createCell(4).setCellValue("运动形式");
			row.createCell(5).setCellValue("运动频率(次/周)");
			row.createCell(6).setCellValue("运动时间(分钟/次)");
			row.createCell(7).setCellValue("每次耗能(千卡)");

			list = dataService.getSportsTreatmentListForExport();
			if (list != null && list.size() > 0) {
				for (int i = 0; i < list.size(); i++) {
					row = sheet.createRow((short) i + 2);
					// 0
					row.createCell(0).setCellValue(list.get(i).getPatientid());
					// 1
					row.createCell(1)
							.setCellValue(list.get(i).getPatientName());
					// 2
					row.createCell(2).setCellValue(list.get(i).getStarttime());
					// 3
					row.createCell(3).setCellValue(list.get(i).getEndtime());
					// 4
					row.createCell(4).setCellValue(list.get(i).getSporttype());
					// 5
					Integer itg1 = list.get(i).getSportsfreq();
					if (itg1 != null) {
						row.createCell(5).setCellValue(itg1);
					}
					// 6
					Double dbl1 = list.get(i).getSportstime();
					if (dbl1 != null) {
						row.createCell(6).setCellValue(dbl1);
					}
					// 7
					dbl1 = list.get(i).getEnergy();
					if (dbl1 != null) {
						row.createCell(7).setCellValue(dbl1);
					}
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void drugTreatmentToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<DrugTreatmentForExport> list = new ArrayList<DrugTreatmentForExport>();
		List<Drug> dlist = dataService.getDrugList();
		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("药物治疗");
			HSSFRow row0 = sheet.createRow((short) 0);
			HSSFRow row = sheet.createRow((short) 1);
			sheet.addMergedRegion(new CellRangeAddress(0, 0, 2, 7));
			row0.createCell(2).setCellValue("第一次");

			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			row.createCell(2).setCellValue("类型");
			row.createCell(3).setCellValue("药名");
			row.createCell(4).setCellValue("单次剂量");
			row.createCell(5).setCellValue("单位");
			row.createCell(6).setCellValue("用法");
			row.createCell(7).setCellValue("频次");

			list = dataService.getDrugTreatmentListForExport();
			int nor = 2;
			if (list != null && list.size() > 0) {
				for (int i = 0; i < list.size(); i++) {
					row = sheet.createRow((short) nor);
					DrugTreatmentForExport dt = list.get(i);
					// 0
					row.createCell(0).setCellValue(dt.getPatientid());
					// 1
					row.createCell(1).setCellValue(dt.getPatientName());
					// 2

					String[] type = null;
					if (dt.getDrugtype() != null
							&& dt.getDrugtype().length() > 0) {
						type = dt.getDrugtype().split(",");
					} else {
						nor++;
						continue;
					}

					String[] name = null;
					if (dt.getDrugname() != null) {
						name = dt.getDrugname().split(",");
					}

					String[] ammount = null;
					if (dt.getAmount() != null) {
						ammount = dt.getAmount().split(",");
					}

					String[] units = { "", "mg", "μg", "U", "g" };
					String[] unit = null;
					if (dt.getTakeunit() != null) {
						unit = dt.getTakeunit().split(",");
					}

					String[] methods = { "", "口服", "水煎服", "皮下注射", "静推", "静滴" };
					String[] method = null;
					if (dt.getTakemethod() != null) {
						method = dt.getTakemethod().split(",");
					}

					String[] freqs = { "", "1/日", "2/日", "3/日", "4/日", "早餐",
							"中餐", "晚餐", "睡前", "10pm", "其他" };
					String[] freq = null;
					if (dt.getTakefreq() != null) {
						freq = dt.getTakefreq().split(",");
					}
					if (type.length < 1) {
						continue;
					}
					for (int j = 0; j < type.length; j++) {
						if (j > 0) {
							nor++;
							row = sheet.createRow((short) nor);
						}

						for (int k = 0; k < dlist.size(); k++) {
							Drug d = dlist.get(k);
							if (type[j].trim().equals(d.getDrugid().toString())) {
								row.createCell(2).setCellValue(d.getDrugname());
							}
						}
						for (int k = 0; k < dlist.size(); k++) {
							Drug d = dlist.get(k);
							if (name[j].trim().equals(d.getDrugid().toString())) {
								row.createCell(3).setCellValue(d.getDrugname());
							}
						}
						if (ammount != null && ammount.length == type.length) {
							row.createCell(4).setCellValue(ammount[j]);
						}
						if (unit != null && unit.length == type.length) {
							row.createCell(5).setCellValue(
									units[Integer.parseInt(unit[j])]);
						}
						if (method != null && method.length == type.length) {
							row.createCell(6).setCellValue(
									methods[Integer.parseInt(method[j])]);
						}
						if (freq != null && freq.length == type.length) {
							row.createCell(7).setCellValue(
									freqs[Integer.parseInt(freq[j])]);
						}

					}
					nor++;
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void physicalSurveyResultToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<PhysicalSurveyResultForExport> list = new ArrayList<PhysicalSurveyResultForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("体质调查");
			HSSFRow row0 = sheet.createRow((short) 0);
			HSSFRow row = sheet.createRow((short) 1);
			sheet.addMergedRegion(new CellRangeAddress(0, 0, 2, 10));
			row0.createCell(2).setCellValue("第一次");

			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			row.createCell(2).setCellValue("平和质");
			row.createCell(3).setCellValue("气虚质");
			row.createCell(4).setCellValue("阳虚质");
			row.createCell(5).setCellValue("阴虚质");
			row.createCell(6).setCellValue("痰湿质");
			row.createCell(7).setCellValue("湿热质");
			row.createCell(8).setCellValue("血瘀质");
			row.createCell(9).setCellValue("气郁质");
			row.createCell(10).setCellValue("特禀质");

			String[] str = { "平和质", "气虚质", "阳虚质", "阴虚质", "痰湿质", "湿热质", "血瘀质",
					"气郁质", "特禀质" };

			list = dataService.getPhysicalSurveyResultListForExport();
			if (list != null && list.size() > 0) {
				for (int i = 0; i < list.size(); i++) {
					row = sheet.createRow((short) i + 2);
					// 0
					row.createCell(0).setCellValue(list.get(i).getPatientid());
					// 1
					row.createCell(1)
							.setCellValue(list.get(i).getPatientName());
					// 2-10
					String[] str1 = list.get(i).getResult().split(";");
					for (int k = 0; k < str.length; k++) {
						for (int j = 0; j < str1.length; j++) {
							if (str1[j].contains(str[k])) {
								row.createCell(k + 2).setCellValue(str1[j]);
								break;
							}
						}
					}
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void qualitySurveyResultToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<QualitySurveyResultForExport> list = new ArrayList<QualitySurveyResultForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("生存质量");
			HSSFRow row0 = sheet.createRow((short) 0);
			HSSFRow row = sheet.createRow((short) 1);
			sheet.addMergedRegion(new CellRangeAddress(0, 0, 2, 6));
			row0.createCell(2).setCellValue("第一次");

			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			row.createCell(2).setCellValue("生理功能");
			row.createCell(3).setCellValue("心理/精神维度");
			row.createCell(4).setCellValue("社会关系维度");
			row.createCell(5).setCellValue("治疗维度");
			row.createCell(6).setCellValue("总分");

			list = dataService.getQualitySurveyResultListForExport();
			if (list != null && list.size() > 0) {
				for (int i = 0; i < list.size(); i++) {
					row = sheet.createRow((short) i + 2);
					// 0
					row.createCell(0).setCellValue(list.get(i).getPatientid());
					// 1
					row.createCell(1)
							.setCellValue(list.get(i).getPatientName());
					// 2
					Integer itg1 = list.get(i).getTotala();
					if (itg1 != null) {
						row.createCell(2).setCellValue(itg1);
					}
					// 3
					itg1 = list.get(i).getTotalb();
					if (itg1 != null) {
						row.createCell(3).setCellValue(itg1);
					}
					// 4
					itg1 = list.get(i).getTotalc();
					if (itg1 != null) {
						row.createCell(4).setCellValue(itg1);
					}
					// 5
					itg1 = list.get(i).getTotald();
					if (itg1 != null) {
						row.createCell(5).setCellValue(itg1);
					}
					// 6
					itg1 = list.get(i).getTotal();
					if (itg1 != null) {
						row.createCell(6).setCellValue(itg1);
					}
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void symptomsSurveyResultToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<SymptomsSurveyResultForExport> list = new ArrayList<SymptomsSurveyResultForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("症候");
			HSSFRow row = sheet.createRow((short) 0);
			List<SymptomsSurvey> sslist = surveyService
					.searchSymptomsSurveyQuestions();
			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			for (int i = 0; i < sslist.size(); i++) {
				SymptomsSurvey ss = sslist.get(i);
				row.createCell(i + 2).setCellValue(ss.getSymptomname());
			}
			int listsize = sslist.size();

			row.createCell(listsize + 3).setCellValue("气虚");
			row.createCell(listsize + 4).setCellValue("血虚");
			row.createCell(listsize + 5).setCellValue("阴虚");
			row.createCell(listsize + 6).setCellValue("阳虚");
			row.createCell(listsize + 7).setCellValue("风");
			row.createCell(listsize + 8).setCellValue("湿");
			row.createCell(listsize + 9).setCellValue("燥");
			row.createCell(listsize + 10).setCellValue("热");
			row.createCell(listsize + 11).setCellValue("痰");
			row.createCell(listsize + 12).setCellValue("血淤");
			row.createCell(listsize + 13).setCellValue("气滞");
			row.createCell(listsize + 14).setCellValue("肝");
			row.createCell(listsize + 15).setCellValue("心");
			row.createCell(listsize + 16).setCellValue("脾");
			row.createCell(listsize + 17).setCellValue("肺");
			row.createCell(listsize + 18).setCellValue("肾");
			row.createCell(listsize + 19).setCellValue("外向兴奋型");
			row.createCell(listsize + 20).setCellValue("内向抑郁型");

			list = dataService.getSymptomsSurveyResultListForExport();
			if (list != null && list.size() > 0) {
				for (int i = 0; i < list.size(); i++) {
					row = sheet.createRow((short) i + 1);
					// 0
					row.createCell(0).setCellValue(list.get(i).getPatientid());
					// 1
					row.createCell(1)
							.setCellValue(list.get(i).getPatientName());
					// 2
					String[] rs = list.get(i).getAnswer().split(",");
					for (int j = 0; j < sslist.size(); j++) {
						if (j > rs.length) {
							break;
						}
						SymptomsSurvey ss = sslist.get(j);
						String opt = "";
						if (ss.getSymptomname().equals("舌色")) {
							String[] str = { "淡白", "红", "紫暗" };
							opt = str[Integer.parseInt(rs[j])];
						} else if (ss.getSymptomname().equals("舌形")) {
							String[] str = { "胖大", "齿痕", "瘀斑瘀点", "裂纹" };
							opt = str[Integer.parseInt(rs[j])];
						} else if (ss.getSymptomname().equals("苔色")) {
							String[] str = { "白", "黄", "灰", "黑" };
							opt = str[Integer.parseInt(rs[j])];
						} else if (ss.getSymptomname().equals("苔质")) {
							String[] str = { "薄苔", "腻苔", "少苔", "剥苔" };
							opt = str[Integer.parseInt(rs[j])];
						} else if (ss.getSymptomname().equals("脉象")) {
							String[] str = { "平", "细", "弱", "弦", "滑", "涩", "数",
									"迟", "结代" };
							opt = str[Integer.parseInt(rs[j])];
						} else {
							String[] str = { "无", "轻", "中", "重" };
							opt = str[Integer.parseInt(rs[j])];
						}
						row.createCell(j + 2).setCellValue(opt);
					}

					Integer itg = list.get(i).getQixu();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 3).setCellValue(str[itg]);
					}
					itg = list.get(i).getXuexu();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 4).setCellValue(str[itg]);
					}
					itg = list.get(i).getYinxu();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 5).setCellValue(str[itg]);
					}
					itg = list.get(i).getYangxu();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 6).setCellValue(str[itg]);
					}
					itg = list.get(i).getFeng();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 7).setCellValue(str[itg]);
					}
					itg = list.get(i).getShi();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 8).setCellValue(str[itg]);
					}
					itg = list.get(i).getZao();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 9).setCellValue(str[itg]);
					}
					itg = list.get(i).getRe();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 10).setCellValue(str[itg]);
					}
					itg = list.get(i).getTan();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 11).setCellValue(str[itg]);
					}
					itg = list.get(i).getXueyu();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 12).setCellValue(str[itg]);
					}
					itg = list.get(i).getQizhi();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 13).setCellValue(str[itg]);
					}
					itg = list.get(i).getGan();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 14).setCellValue(str[itg]);
					}
					itg = list.get(i).getXin();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 15).setCellValue(str[itg]);
					}
					itg = list.get(i).getPi();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 16).setCellValue(str[itg]);
					}
					itg = list.get(i).getFei();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 17).setCellValue(str[itg]);
					}
					itg = list.get(i).getShen();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 18).setCellValue(str[itg]);
					}
					itg = list.get(i).getQinzhik();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 19).setCellValue(str[itg]);
					}
					itg = list.get(i).getQinzhid();
					if (itg != null && itg > -1 && itg < 4) {
						String[] str = { "无", "轻", "中", "重" };
						row.createCell(listsize + 20).setCellValue(str[itg]);
					}
				}

			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void symptomsResultToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<SymptomsSurveyResultForExport> list = new ArrayList<SymptomsSurveyResultForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("证候判别结果");
			HSSFRow row0 = sheet.createRow((short) 0);
			HSSFRow row = sheet.createRow((short) 1);
			row0.createCell(2).setCellValue("第一次");

			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			row.createCell(2).setCellValue("证型");

			list = dataService.getSymptomsSurveyResultListForExport();
			if (list != null && list.size() > 0) {
				for (int i = 0; i < list.size(); i++) {
					row = sheet.createRow((short) i + 2);
					// 0
					row.createCell(0).setCellValue(list.get(i).getPatientid());
					// 1
					row.createCell(1)
							.setCellValue(list.get(i).getPatientName());
					// 2
					row.createCell(2).setCellValue(list.get(i).getResult());
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void concurrentToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<ConcurrentResultForExport> list = new ArrayList<ConcurrentResultForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("伴随并发症情况");
			HSSFRow row0 = sheet.createRow((short) 0);
			HSSFRow row = sheet.createRow((short) 1);
			sheet.addMergedRegion(new CellRangeAddress(0, 0, 2, 4));
			sheet.addMergedRegion(new CellRangeAddress(0, 0, 5, 7));
			sheet.addMergedRegion(new CellRangeAddress(0, 0, 8, 10));
			row0.createCell(2).setCellValue("第一次");
			row0.createCell(5).setCellValue("第一次");
			row0.createCell(8).setCellValue("第一次");

			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			row.createCell(2).setCellValue("证型");

			list = dataService.getConcurrentResultListForExport();
			if (list != null && list.size() > 0) {
				for (int i = 0; i < list.size(); i++) {
					row = sheet.createRow((short) i + 2);
					// 0
					row.createCell(0).setCellValue(list.get(i).getPatientid());
					// 1
					row.createCell(1)
							.setCellValue(list.get(i).getPatientName());
					// 2
					// row.createCell(2).setCellValue(list.get(i).getResult());
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			if (null != fileOut) {
				fileOut.close();
			}
		}
	}

	public void bloodSugarIndexToExcel(String filename) throws IOException {
		FileOutputStream fileOut = null;
		List<LabSugarForExport> list = new ArrayList<LabSugarForExport>();

		try {
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("血糖指标");
			HSSFRow row = sheet.createRow((short) 0);
			
			String[] str1={"","早餐前（空腹）","午餐前","晚餐前","早餐后2h","午餐后2h","晚餐后2h","10pm","12pm","3am","随机"};
			String[] str2={"","毛细血管血糖(CBG)","静脉血清血糖(VSG)"};
			
			row.createCell(0).setCellValue("患者编号");
			row.createCell(1).setCellValue("患者姓名");
			row.createCell(2).setCellValue("葡萄糖检查时间");
			row.createCell(3).setCellValue("检查方式");
			row.createCell(4).setCellValue("血糖值(mmol/L)");
			row.createCell(5).setCellValue("糖化血红蛋白%");
			row.createCell(6).setCellValue("糖化血清蛋白(mmol/L)");
			row.createCell(7).setCellValue("血酮体(mg/L)");
			row.createCell(8).setCellValue("乳酸(mmol/L)");

			list = dataService.getLabSugarListForExport();
			int nol=2;
			if (list != null && list.size() > 0) {

				for (int i = 0; i < list.size(); i++) {
					row = sheet.createRow((short) nol++);
					LabSugarForExport rec=list.get(i);
					if(rec==null){
						continue;
					}
					// 0
					row.createCell(0).setCellValue(list.get(i).getPatientid());
					// 1
					row.createCell(1)
							.setCellValue(list.get(i).getPatientName());
					// 2
					Integer itg=rec.getTesttime();
					if(itg!=null  && itg>0 && itg<str1.length){
						row.createCell(2).setCellValue(str1[itg]);
					}
					//3
					itg=rec.getTesttime();
					if(itg!=null  && itg>0 && itg<str2.length){
						row.createCell(3).setCellValue(str2[itg]);
					}
					//4
					Double dbl=rec.getSugar();
					if(dbl!=null){
						row.createCell(4).setCellValue(dbl);
					}
					//5
					dbl=rec.getXuehong();
					if(dbl!=null){
						row.createCell(5).setCellValue(dbl);
					}
					//6
					dbl=rec.getXueqing();
					if(dbl!=null){
						row.createCell(6).setCellValue(dbl);
					}
					//7
					dbl=rec.getTongti();
					if(dbl!=null){
						row.createCell(7).setCellValue(dbl);
					}
					//8
					dbl=rec.getRusuan();
					if(dbl!=null){
						row.createCell(8).setCellValue(dbl);
					}
				}
			}

			String dir = filename.substring(0, filename.lastIndexOf("/") - 1);
			File fDir = new File(dir);
			if (!fDir.exists()) {
				FileUtils.forceMkdir(fDir);
			}
			fileOut = new FileOutputStream(filename);
			wb.write(fileOut);
			fileOut.flush();
			fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {

			if (null != fileOut) {
				fileOut.close();
			}
		}
	}
	
	public void excelToHospital(String filename) throws Exception {
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();

			if (nol < 2) {
				return;
			}
			List<ResearchGroupForExport> rgs = dataService.getAllGroupList();

			User user = null;
			String currentDanwei = "";
			List<InterGroupUser> igus = null;
			for (int i = 1; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行

				boolean newUser = false;
				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				// 医院名称
				if (row.getCell(0) == null) {
				} else if (row.getCell(0).getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String username = row.getCell(0).getStringCellValue()
							.trim();
					if (username != null && username.length() > 0) {
						if (user != null) {
							dataService.importUser(user, igus);
						}

						currentDanwei = username;
						newUser = true;
						igus = new ArrayList<InterGroupUser>();
						user = new User();
						user.setDanwei(username);

					} else {
						newUser = false;
					}

				} else {// 数值
				}

				if (newUser) {
					// 单位地址
					if (row.getCell(2) == null) {
					} else if (row.getCell(2).getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
						String address = row.getCell(2).getStringCellValue()
								.trim();
						user.setAddress(address);
					} else {// 数值
					}

					// 联系人姓名
					if (row.getCell(3) == null) {
					} else if (row.getCell(3).getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
						String relateperson = row.getCell(3)
								.getStringCellValue().trim();
						user.setRelateperson(relateperson);
					} else {// 数值
					}

					// 联系电话
					if (row.getCell(4) == null) {
					} else if (row.getCell(4).getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
						String phonenumber = row.getCell(4)
								.getStringCellValue().trim();
						user.setPhonenumber(phonenumber);
					} else {// 数值
					}

				}

				InterGroupUser igu = new InterGroupUser();
				// 临床组别
				if (row.getCell(5) == null && row.getCell(6) == null) {
				} else if (row.getCell(5).getCellType() != 0
						&& row.getCell(6).getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String groupBh = row.getCell(5).getStringCellValue().trim();
					String groupName = row.getCell(6).getStringCellValue()
							.trim();
					for (int j = 0; j < rgs.size(); j++) {
						ResearchGroupForExport rg = rgs.get(j);
						if (rg.getGroupbh().equals(groupBh)
								&& rg.getGroupname().equals(groupName)) {
							igu.setResearchgroupid(rg.getResearchgroupid());
							igus.add(igu);
							break;
						}
					}
				} else {// 数值
				}

				// //联系人姓名
				// if (row.getCell(3) == null) {
				// } else if (row.getCell(3).getCellType() != 0) {//
				// 如果EXCEL表格中的数据类型为字符串型
				//
				// } else {//数值
				// int patientcount = (int)row.getCell(3).getNumericCellValue();
				// rg.setPatientcount(patientcount);
				// }
			}
			if (user != null) {
				dataService.importUser(user, igus);
			}

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	public void excelToGroup(String filename) throws Exception {
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();

			List<User> users = dataService.getUserList();
			List<TableForPatient> tb = dataService.getAllTbInfo();

			if (nol < 2) {
				return;
			}

			for (int i = 1; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行
				ResearchGroup rg = new ResearchGroup();
				InterGroupUser igu = null;

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				// 医院 user
				if (row.getCell(0) == null) {
				} else if (row.getCell(0).getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String username = row.getCell(0).getStringCellValue()
							.trim();
					for (int j = 0; j < users.size(); j++) {
						if (username.equals(users.get(j).getDanwei())) {
							igu = new InterGroupUser();
							igu.setUserid(users.get(j).getUserid());
							break;
						}
					}
				} else {// 数值
				}

				// 临床分组
				if (row.getCell(1) == null && row.getCell(2) == null) {
				} else if (row.getCell(1).getCellType() != 0
						&& row.getCell(2).getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String groupBh = row.getCell(1).getStringCellValue().trim();
					String groupName = row.getCell(2).getStringCellValue()
							.trim();
					rg.setGroupbh(groupBh);
					rg.setGroupname(groupName);
				} else {// 数值
				}

				// 随访周期 timeLong timeType
				if (row.getCell(4) == null) {
				} else if (row.getCell(4).getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String time = row.getCell(4).getStringCellValue().trim();
					if (time.endsWith("个月")) {
						rg.setTimetype(1);
						String timelong = time.substring(0, time.length() - 2);
						rg.setTimelong(Integer.parseInt(timelong));
					} else if (time.endsWith("日")) {
						rg.setTimetype(0);
						String timelong = time.substring(0, time.length() - 1);
						rg.setTimelong(Integer.parseInt(timelong));
					} else if (time.endsWith("年")) {
						rg.setTimetype(2);
						String timelong = time.substring(0, time.length() - 1);
						rg.setTimelong(Integer.parseInt(timelong));
					} else {
						rg.setTimetype(0);
					}
				} else {// 数值

				}

				// 状态 groupStatus
				if (row.getCell(5) == null) {

				} else if (row.getCell(5).getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String temp = row.getCell(5).getStringCellValue().trim();
					List<Long> ids = new ArrayList<Long>();
					if (temp != null && temp.length() > 2) {
						String content = temp.substring(1, temp.length() - 1);
						String[] survey = content.split(",");
						for (int k = 0; k < survey.length; k++) {
							for (int j = 0; j < tb.size(); j++) {
								if (survey[k].trim().equals(
										tb.get(j).getTbname())) {
									ids.add(tb.get(j).getTbid());
									break;
								}
							}
						}
						// List<Long>
						// ids=dataService.gettSurveyIdsByContent(content);
						temp = ids.toString();
						String idsstr = temp.substring(1, temp.length() - 1);
						rg.setContent(idsstr);
					}
				} else {// 数值

				}

				dataService.importResearchGroup(rg, igu);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	public void excelToPatientList(String filename) throws Exception {
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();
			if (nol < 2) {
				return;
			}
			List<User> users = dataService.getUserList();
			List<ResearchGroupForExport> groups = dataService.getAllGroupList();

			for (int i = 1; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行
				Patient patient = new Patient();
				// PatientForExport patient = new PatientForExport();
				InterPatientUser ipu = new InterPatientUser();
				InterPatientGroup ipg = null;

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				/** */
				/** 将EXCEL中的第 i 行，第一列的值插入到实例中 */
				if (row.getCell(0) == null) {

				} else if (row.getCell(0).getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String hospital = row.getCell(0).getStringCellValue()
							.trim();
					for (int j = 0; j < users.size(); j++) {
						if (users.get(j).getDanwei().equals(hospital)) {
							ipu.setUserid(users.get(j).getUserid());
							break;
						}
					}
				} else {// 数值

				}

				// 临床分组
				if (row.getCell(1) == null && row.getCell(2) == null) {

				} else if (row.getCell(1).getCellType() != 0
						&& row.getCell(2).getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String groupBh = row.getCell(1).getStringCellValue().trim();
					String groupName = row.getCell(2).getStringCellValue()
							.trim();
					for (int j = 0; j < groups.size(); j++) {
						if (groups.get(j).getGroupbh().equals(groupBh)
								&& groups.get(j).getGroupname()
										.equals(groupName)) {
							ipg = new InterPatientGroup();
							ipg.setResearchgroupid(groups.get(j)
									.getResearchgroupid());
						}
					}
				} else {// 数值

				}

				// if (row.getCell(2) == null) {
				//
				// } else if (row.getCell(0).getCellType() != 0) {//
				// 如果EXCEL表格中的数据类型为字符串型
				// String hospital = row.getCell(0).getStringCellValue().trim();
				// patient.set(hospital);
				// } else {//数值
				//
				// }

				if (row.getCell(4) == null) {

				} else if (row.getCell(4).getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String name = row.getCell(4).getStringCellValue().trim();
					patient.setPatientname(name);
				} else {// 数值

				}

				if (row.getCell(5) == null) {

				} else if (row.getCell(5).getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String address = row.getCell(5).getStringCellValue().trim();
					patient.setAddress(address);
				} else {// 数值

				}

				if (row.getCell(6) == null) {

				} else if (row.getCell(6).getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String telephone = row.getCell(6).getStringCellValue()
							.trim();
					patient.setTelephone(telephone);
				} else {// 数值

				}

				if (row.getCell(7) == null) {

				} else if (row.getCell(7).getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String starttime = row.getCell(7).getStringCellValue()
							.trim();
					patient.setStarttime(starttime);
				} else {// 数值

				}

				if (row.getCell(8) == null) {

				} else if (row.getCell(8).getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String followtime = row.getCell(8).getStringCellValue()
							.trim();
					patient.setFollowtime(followtime);
				} else {// 数值

				}

				if (row.getCell(9) == null) {

				} else if (row.getCell(9).getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String statusstr = row.getCell(9).getStringCellValue()
							.trim();
					int status = 0;
					if (statusstr != null) {
						if (statusstr.equals("进行中")) {
							status = 0;
						} else if (statusstr.equals("死亡")) {
							status = 1;
						} else if (statusstr.equals("失访")) {
							status = 2;
						} else if (statusstr.equals("结束")) {
							status = 3;
						} else if (statusstr.equals("退出")) {
							status = 4;
						}
						patient.setPatientstatus(status);
					}
				} else {// 数值

				}

				dataService.importPatient(patient, ipu, ipg);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}

	}

	public void excelToPatient(String filename) throws Exception {
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();
			if (nol < 2) {
				return;
			}
			List<User> users = dataService.getUserList();
			List<ResearchGroupForExport> groups = dataService.getAllGroupList();

			for (int i = 1; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行
				Patient patient = new Patient();
				// PatientForExport patient = new PatientForExport();
				// InterPatientUser ipu=new InterPatientUser();
				InterPatientGroup ipg = new InterPatientGroup();

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				/** */
				/** 将EXCEL中的第 i 行，第一列的值插入到实例中 */
				HSSFCell cell = row.getCell(0);
				// if (cell == null) {
				// } else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				// ipg.setPatientid(Long.parseLong(cell.getStringCellValue()));
				// } else {//数值
				// }

				cell = row.getCell(1);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					patient.setPatientname(cell.getStringCellValue());
				} else {// 数值
				}

				cell = row.getCell(2);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String[] job = cell.getStringCellValue().split("-");
					int wt1 = this.getNoByString(job[0], new String[] { "非军人",
							"军人" });
					int wt2 = 0;
					if (wt1 == 0) {
						wt2 = this.getNoByString(job[1], new String[] { "公务员",
								"工厂企业", "事业单位", "服务业", "商业", "医教研", "农林牧渔劳动者",
								"自由职业者", "其他劳动者" });
					} else if (wt1 == 1) {
						wt2 = this.getNoByString(job[1], new String[] { "陆军",
								"海军", "空军", "二炮", "其他" });
					}
					patient.setWorktype1(wt1);
					patient.setWorktype2(wt2);
				} else {// 数值
				}

				cell = row.getCell(3);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					patient.setWorkplace(cell.getStringCellValue());
				} else {// 数值
				}

				cell = row.getCell(4);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					patient.setAddress(cell.getStringCellValue());
				} else {// 数值
				}

				cell = row.getCell(5);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					patient.setZipcode(cell.getStringCellValue());
				} else {// 数值
				}

				cell = row.getCell(6);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					patient.setTelephone(cell.getStringCellValue());
				} else {// 数值
				}

				cell = row.getCell(7);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					patient.setRelate(cell.getStringCellValue());
				} else {// 数值
				}

				cell = row.getCell(8);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					patient.setRelatephone(cell.getStringCellValue());
				} else {// 数值
				}

				cell = row.getCell(9);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					ipg.setResearchgroupid((long) cell.getNumericCellValue());
				}

				cell = row.getCell(11);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String str1 = cell.getStringCellValue();
					int int1 = this.getNoByString(str1, new String[] { "进行中",
							"死亡", "失访", "结束", "退出" });
					patient.setPatientstatus(int1);
				} else {// 数值
				}

				dataService.importPatient(patient, null, ipg);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	private void excelToSymptomsResult(String filename2) throws Exception {
		// TODO Auto-generated method stub
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();
			if (nol < 2) {
				return;
			}

			for (int i = 2; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行
				SymptomsSurveyResult rec = new SymptomsSurveyResult();

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				/** */
				/** 将EXCEL中的第 i 行，第一列的值插入到实例中 */
				HSSFCell cell = row.getCell(0);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setPatientid((long) cell.getNumericCellValue());
				}

				cell = row.getCell(1);

				cell = row.getCell(2);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					rec.setResult(cell.getStringCellValue());
				} else {// 数值
				}

				dataService.importSymptomsSurveyResult(rec);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	private void excelToQualitySurveyResult(String filename2) throws Exception {
		// TODO Auto-generated method stub
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();
			if (nol < 2) {
				return;
			}

			for (int i = 2; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行
				QualitySurveyResult rec = new QualitySurveyResult();

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				/** */
				/** 将EXCEL中的第 i 行，第一列的值插入到实例中 */
				HSSFCell cell = row.getCell(0);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setPatientid((long) cell.getNumericCellValue());
				}

				cell = row.getCell(2);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setTotala((int) cell.getNumericCellValue());
				}

				cell = row.getCell(3);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setTotalb((int) cell.getNumericCellValue());
				}

				cell = row.getCell(4);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setTotalc((int) cell.getNumericCellValue());
				}

				cell = row.getCell(5);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setTotald((int) cell.getNumericCellValue());
				}

				cell = row.getCell(6);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setTotal((int) cell.getNumericCellValue());
				}

				dataService.importQualitySurveyResult(rec);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	private void excelToSymptomsSurveyResult(String filename2) throws Exception {
		// TODO Auto-generated method stub
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();
			if (nol < 2) {
				return;
			}

			for (int i = 1; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);//
				SymptomsSurveyResult rec = new SymptomsSurveyResult();

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				/** */
				/** 将EXCEL中的第 i 行，第一列的值插入到实例中 */
				HSSFCell cell = row.getCell(0);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setPatientid((long) cell.getNumericCellValue());
				}

				cell = row.getCell(1);
				String[][] str = { { "无", "轻", "中", "重" }, { "淡白", "红", "紫暗" },
						{ "胖大", "齿痕", "瘀斑瘀点", "裂纹" }, { "白", "黄", "灰", "黑" },
						{ "薄苔", "腻苔", "少苔", "剥苔" },
						{ "平", "细", "弱", "弦", "滑", "涩", "数", "迟", "结代" } };
				StringBuilder ans = new StringBuilder("");
				for (int j = 2; j < 79; j++) {
					cell = row.getCell(j);
					if (cell == null) {
					} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
						String answer = cell.getStringCellValue();
						for (int m = 0; m < str.length; m++) {
							int no = getNoByString(answer, str[m]);
							if (no > -1) {
								ans.append("," + no);
								break;
							}
						}
					} else {// 数值
					}
				}
				rec.setAnswer(ans.substring(1));

				cell = row.getCell(80);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setQixu(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(81);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setXuexu(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(82);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setYinxu(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(83);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setYangxu(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(84);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setFeng(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(85);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setShi(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(86);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setZao(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(87);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setRe(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(88);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setTan(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(89);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setXueyu(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(90);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setQizhi(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(91);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setGan(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(92);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setXin(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(93);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setPi(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(94);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setFei(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(95);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setShen(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(96);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setQinzhik(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(97);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String s = cell.getStringCellValue();
					if (s != null && s.length() > 0) {
						int no = getNoByString(s, str[0]);
						if (no > -1) {
							rec.setQinzhid(no);
						}
					}
				} else {// 数值
				}

				dataService.importSymptomsSurveyResult(rec);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	private void excelToPhysicalSurveyResult(String filename2) throws Exception {
		// TODO Auto-generated method stub
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();
			if (nol < 3) {
				return;
			}

			String[] str = { "平和质", "气虚质", "阳虚质", "阴虚质", "痰湿质", "湿热质", "血瘀质",
					"气郁质", "特禀质" };

			for (int i = 2; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行
				PhysicalSurveyResult rec = new PhysicalSurveyResult();

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				/** */
				/** 将EXCEL中的第 i 行，第一列的值插入到实例中 */
				HSSFCell cell = row.getCell(0);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setPatientid((long) cell.getNumericCellValue());
				}
				StringBuilder result = new StringBuilder("");
				for (int j = 2; j < 11; j++) {
					cell = row.getCell(j);
					if (cell == null) {
					} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
						String s = cell.getStringCellValue();
						if (s != null && s.length() > 0) {
							result.append(";" + s);
						}
					} else {// 数值

					}
				}
				rec.setResult(result.substring(1));
				dataService.importPhysicalSurveyResult(rec);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	private void excelToDrugTreatment(String filename2) throws Exception {
		// TODO Auto-generated method stub
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();

			if (nol < 2) {
				return;
			}
			String[] units = { "", "mg", "μg", "U", "g" };
			String[] methods = { "", "口服", "水煎服", "皮下注射", "静推", "静滴" };
			String[] freqs = { "", "1/日", "2/日", "3/日", "4/日", "早餐", "中餐",
					"晚餐", "睡前", "10pm", "其他" };
			List<Drug> dlist = dataService.getDrugList();
			DrugTreatment rec = null;
			for (int i = 2; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				/** */
				/** 将EXCEL中的第 i 行，第一列的值插入到实例中 */
				HSSFCell cell = row.getCell(0);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					Double lid = cell.getNumericCellValue();
					if (lid != null) {
						if (rec != null) {
							dataService.importDrugTreatment(rec);
						}
						rec = new DrugTreatment();
						rec.setPatientid((long) (double) lid);
					}
				}

				cell = row.getCell(1);

				cell = row.getCell(2);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String str = cell.getStringCellValue();
					if (str != null && str.length() > 0) {
						for (int j = 0; j < dlist.size(); j++) {
							Drug d = dlist.get(j);
							if (d.getDrugname().equals(str.trim())) {
								String temp = rec.getDrugtype();
								if (temp == null || temp.length() < 1) {
									rec.setDrugtype(d.getDrugid().toString());
								} else {
									rec.setDrugtype(temp + ","
											+ d.getDrugid().toString());
								}
							}
						}
					} else {
						String temp = rec.getDrugtype();
						if (temp == null || temp.length() < 1) {
							rec.setDrugtype("0");
						} else {
							rec.setDrugtype(temp + "," + "0");
						}
					}
				} else {// 数值
				}

				cell = row.getCell(3);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String str = cell.getStringCellValue();
					if (str != null && str.length() > 0) {
						for (int j = 0; j < dlist.size(); j++) {
							Drug d = dlist.get(j);
							if (d.getDrugname().trim().equals(str.trim())) {
								String temp = rec.getDrugname();
								if (temp == null || temp.length() < 1) {
									rec.setDrugname(d.getDrugid().toString());
								} else {
									rec.setDrugname(temp + ","
											+ d.getDrugid().toString());
								}
							}
						}
					} else {
						String temp = rec.getDrugname();
						if (temp == null || temp.length() < 1) {
							rec.setDrugname("0");
						} else {
							rec.setDrugname(temp + "," + "0");
						}
					}
				} else {// 数值
				}

				cell = row.getCell(4);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String str = cell.getStringCellValue();
					if (str != null && str.length() > 0) {
						String temp = rec.getAmount();
						if (temp == null || temp.length() < 1) {
							rec.setAmount(str);
						} else {
							rec.setAmount(temp + "," + str);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(5);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String str = cell.getStringCellValue();
					int no = getNoByString(str, units);
					if (str != null && str.length() > 0) {
						String temp = rec.getTakeunit();
						if (temp == null || temp.length() < 1) {
							rec.setTakeunit(no + "");
						} else {
							rec.setTakeunit(temp + "," + no);
						}
					} else {
						String temp = rec.getTakeunit();
						if (temp == null || temp.length() < 1) {
							rec.setTakeunit("0");
						} else {
							rec.setTakeunit(temp + "," + "0");
						}
					}
				} else {// 数值
				}

				cell = row.getCell(6);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String str = cell.getStringCellValue();
					int no = getNoByString(str, methods);
					if (str != null && str.length() > 0) {
						String temp = rec.getTakemethod();
						if (temp == null || temp.length() < 1) {
							rec.setTakemethod(no + "");
						} else {
							rec.setTakemethod(temp + "," + no);
						}
					} else {
						String temp = rec.getTakemethod();
						if (temp == null || temp.length() < 1) {
							rec.setTakemethod("0");
						} else {
							rec.setTakemethod(temp + "," + "0");
						}
					}
				} else {// 数值
				}

				cell = row.getCell(7);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String str = cell.getStringCellValue();
					int no = getNoByString(str, freqs);
					if (str != null && str.length() > 0) {
						String temp = rec.getTakefreq();
						if (temp == null || temp.length() < 1) {
							rec.setTakefreq(no + "");
						} else {
							rec.setTakefreq(temp + "," + no);
						}
					} else {
						String temp = rec.getTakefreq();
						if (temp == null || temp.length() < 1) {
							rec.setTakefreq("0");
						} else {
							rec.setTakefreq(temp + "," + "0");
						}
					}
				} else {// 数值
				}
				// dataService.importSymptomsSurveyResult(rec);
			}
			if (rec != null) {
				dataService.importDrugTreatment(rec);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	private void excelToSportsSuifang(String filename2) throws Exception {
		// TODO Auto-generated method stub
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();
			if (nol < 3) {
				return;
			}
			String[] yesno = { "", "是", "否" };
			String[] tired = { "", "没有感觉", "非常轻松", "比较轻松", "轻松", "稍微有点累",
					"有点累", "比较累", "非常累", "因累而有不适感", "因累身体不适并难以忍受", "累到极点" };
			for (int i = 2; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行
				SportsSuifang rec = new SportsSuifang();

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				/** */
				/** 将EXCEL中的第 i 行，第一列的值插入到实例中 */
				HSSFCell cell = row.getCell(0);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setPatientid((long) cell.getNumericCellValue());
				}

				cell = row.getCell(1);

				cell = row.getCell(2);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, yesno);
						if (no > 0 && no < 3) {
							rec.setIsfollow(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(3);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, yesno);
						if (no > 0 && no < 3) {
							rec.setOthertype(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(4);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						rec.setSportstype(tstr);
					}
				} else {// 数值
				}

				cell = row.getCell(5);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setSportsfreq((int) (double) tdbl);
					}
				}

				cell = row.getCell(6);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setSportstime(tdbl);
					}
				}

				cell = row.getCell(7);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setMorningrate((int) (double) tdbl);
					}
				}

				cell = row.getCell(8);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setRatea((int) (double) tdbl);
					}
				}

				cell = row.getCell(9);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setRateb((int) (double) tdbl);
					}
				}

				cell = row.getCell(10);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setHuxia((int) (double) tdbl);
					}
				}

				cell = row.getCell(11);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setHuxib((int) (double) tdbl);
					}
				}

				cell = row.getCell(12);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setXuetanga(tdbl);
					}
				}

				cell = row.getCell(13);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setXuetangb(tdbl);
					}
				}

				cell = row.getCell(14);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, tired);
						if (no > 0 && no < 12) {
							rec.setFeel(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(15);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, new String[] { "否", "是" });
						if (no > -1 && no < 2) {
							rec.setLowsugar(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(16);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setLowcount((int) (double) tdbl);
					}
				}
				dataService.importSportsSuifang(rec);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	private void excelToSportsTreatment(String filename2) throws Exception {
		// TODO Auto-generated method stub
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();
			if (nol < 3) {
				return;
			}
			for (int i = 2; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行
				SportsTreatment rec = new SportsTreatment();

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				/** */
				/** 将EXCEL中的第 i 行，第一列的值插入到实例中 */
				HSSFCell cell = row.getCell(0);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setPatientid((long) cell.getNumericCellValue());
				}

				cell = row.getCell(1);

				cell = row.getCell(2);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						rec.setStarttime(tstr);
					}
				} else {// 数值
				}

				cell = row.getCell(3);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						rec.setEndtime(tstr);
					}
				} else {// 数值
				}

				cell = row.getCell(4);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						rec.setSporttype(tstr);
					}
				} else {// 数值
				}

				cell = row.getCell(5);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setSportsfreq((int) (double) tdbl);
					}
				}

				cell = row.getCell(6);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setSportstime(tdbl);
					}
				}

				cell = row.getCell(7);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setEnergy(tdbl);
					}
				}

				dataService.importSportsTreatment(rec);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	private void excelToSportsSurvey(String filename2) throws Exception {
		// TODO Auto-generated method stub
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();
			if (nol < 3) {
				return;
			}
			String[] yesno = { "", "是", "否" };
			String[] strength = { "卧床休息", "轻度活动", "中度活动", "重度活动" };
			String[] unwilling = { "", "没兴趣", "没时间", "惰性，没有毅力坚持",
					"体力工作，没有必要参加", "缺乏场地设施", "身体不适，不宜参加",
					"运动后身体不适（头晕、心慌、胸闷、胃痛、低血糖反应）" };
			String[] type = { "轻度活动（种花、家务、步行等)", "中度活动（慢跑、羽毛球、健身操、健身气功、跳舞等)",
					"重度活动（举杠铃、游泳、跳绳等）" };
			String[] method = { "", "个人运动", "集体运动" };
			String[] time = { "", "早上", "上午", "下午", "晚饭后" };
			String[] freq = { "", "1~2次", "3~4次", "5~7次" };
			String[] last = { "", "30min", "30-60min", "60-90min", "90min" };
			for (int i = 2; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行
				SportsSurvey rec = new SportsSurvey();

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				/** */
				/** 将EXCEL中的第 i 行，第一列的值插入到实例中 */
				HSSFCell cell = row.getCell(0);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setPatientid((long) cell.getNumericCellValue());
				}

				cell = row.getCell(1);

				cell = row.getCell(2);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, strength);
						if (no > -1 && no < 4) {
							rec.setWorksports(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(3);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, yesno);
						if (no > 0 && no < 3) {
							rec.setIsregular(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(4);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						String[] reasons = tstr.split("。");
						String temp = "";
						if (reasons.length == 1) {
							int no = getNoByString(reasons[0], unwilling);
							if (no > -1) {
								rec.setNoreason(no + "");
							}
						} else if (reasons.length > 1) {
							for (int j = 0; j < reasons.length; j++) {
								int no = getNoByString(reasons[j], unwilling);
								temp += "," + no;
							}
							rec.setNoreason(temp.substring(1));
						}
					}
				} else {// 数值
				}

				cell = row.getCell(5);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, type);
						if (no > -1 && no < 3) {
							rec.setSportstype(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(6);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, method);
						if (no > 0 && no < 3) {
							rec.setSportsway(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(7);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, time);
						if (no > 0 && no < 5) {
							rec.setSportstime(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(8);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, freq);
						if (no > 0 && no < 4) {
							rec.setSportscount(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(9);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, last);
						if (no > 0 && no < 5) {
							rec.setSportslast(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(10);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, yesno);
						if (no > 0 && no < 3) {
							rec.setTakemeal(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(11);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, yesno);
						if (no > 0 && no < 3) {
							rec.setTakedrug(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(12);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, yesno);
						if (no > 0 && no < 3) {
							rec.setIshurt(no);
						}
					}
				} else {// 数值
				}

				dataService.importSportsSurvey(rec);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	private void excelToNutritionSuifang(String filename2) throws Exception {
		// TODO Auto-generated method stub
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();
			if (nol < 3) {
				return;
			}
			String[] yesno = { "", "是", "否" };

			for (int i = 2; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行
				NutritionSuifang rec = new NutritionSuifang();

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				/** */
				/** 将EXCEL中的第 i 行，第一列的值插入到实例中 */
				HSSFCell cell = row.getCell(0);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setPatientid((long) cell.getNumericCellValue());
				}

				cell = row.getCell(1);

				cell = row.getCell(2);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, yesno);
						if (no > 0 && no < 3) {
							rec.setRecommend(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(3);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setZhushitotal(tdbl);
					}
				}

				cell = row.getCell(4);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setShucaitotal(tdbl);
					}
				}

				cell = row.getCell(5);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setYuroutotal(tdbl);
					}
				}

				cell = row.getCell(6);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setDoutotal(tdbl);
					}
				}

				cell = row.getCell(7);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setRutotal(tdbl);
					}
				}

				cell = row.getCell(8);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setShuiguototal(tdbl);
					}
				}

				cell = row.getCell(9);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setYouzhitotal(tdbl);
					}
				}

				dataService.importNutritionSuifang(rec);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	private void excelToNutritionTreatment(String filename2) throws Exception {
		// TODO Auto-generated method stub
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();
			if (nol < 3) {
				return;
			}
			String[] yesno = { "", "是", "否" };
			for (int i = 2; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行
				NutritionTreatment rec = new NutritionTreatment();

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				/** */
				/** 将EXCEL中的第 i 行，第一列的值插入到实例中 */
				HSSFCell cell = row.getCell(0);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setPatientid((long) cell.getNumericCellValue());
				}

				cell = row.getCell(1);

				cell = row.getCell(2);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						rec.setStarttime(tstr);
					}
				} else {// 数值
				}

				cell = row.getCell(3);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						rec.setEndtime(tstr);
					}
				} else {// 数值
				}

				cell = row.getCell(4);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, yesno);
						if (no > 0 && no < 3) {
							rec.setSuitfruit(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(5);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, yesno);
						if (no > 0 && no < 3) {
							rec.setLimitmeal(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(6);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setEnergyamount(tdbl);
					}
				}

				cell = row.getCell(7);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setEnergylevel(tdbl);
					}
				}

				dataService.importNutritionTreatment(rec);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	private void excelToNutritionSurvey(String filename2) throws Exception {
		// TODO Auto-generated method stub
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();
			if (nol < 3) {
				return;
			}

			for (int i = 2; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行
				NutritionSurvey rec = new NutritionSurvey();

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				/** */
				/** 将EXCEL中的第 i 行，第一列的值插入到实例中 */
				HSSFCell cell = row.getCell(0);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setPatientid((long) cell.getNumericCellValue());
				}

				cell = row.getCell(1);

				cell = row.getCell(2);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setZhushitotal(tdbl);
					}
				}

				cell = row.getCell(3);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setShucaitotal(tdbl);
					}
				}

				cell = row.getCell(4);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setYuroutotal(tdbl);
					}
				}

				cell = row.getCell(5);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setDoutotal(tdbl);
					}
				}

				cell = row.getCell(6);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setRutotal(tdbl);
					}
				}

				cell = row.getCell(7);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setShuiguototal(tdbl);
					}
				}

				cell = row.getCell(8);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setYouzhitotal(tdbl);
					}
				}

				dataService.importNutritionSurvey(rec);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	private void excelToLabPhysical(String filename2) throws Exception {
		// TODO Auto-generated method stub
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();
			if (nol < 3) {
				return;
			}
			String[] body = { "消瘦", "正常", "超重", "肥胖" };
			String[] pulse = { "", "正常", "减弱", "消失" };
			for (int i = 2; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行
				LabPhysical rec = new LabPhysical();

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				/** */
				/** 将EXCEL中的第 i 行，第一列的值插入到实例中 */
				HSSFCell cell = row.getCell(0);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setPatientid((long) cell.getNumericCellValue());
				}

				cell = row.getCell(1);

				cell = row.getCell(2);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setHeight(tdbl);
					}
				}

				cell = row.getCell(3);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setWeight(tdbl);
					}
				}

				cell = row.getCell(4);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setBmi(tdbl);
					}
				}

				cell = row.getCell(5);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, body);
						if (no > -1 && no < 4) {
							rec.setStyle(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(6);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setWaistline(tdbl);
					}
				}

				cell = row.getCell(7);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setHip(tdbl);
					}
				}

				cell = row.getCell(8);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setWhr(tdbl);
					}
				}

				cell = row.getCell(9);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, pulse);
						if (no > 0 && no < 4) {
							rec.setArterya(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(10);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, pulse);
						if (no > 0 && no < 4) {
							rec.setArteryb(no);
						}
					}
				} else {// 数值
				}

				dataService.importLabPhysical(rec);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	private void excelToConcurrent(String filename2) throws Exception {
		// TODO Auto-generated method stub

	}

	private void excelToFamily(String filename2) throws Exception {
		// TODO Auto-generated method stub
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();
			if (nol < 2) {
				return;
			}
			String[] str1 = { "无", "有", "不详" };
			String[] str2 = { "1型", "2型", "妊娠糖尿病", "其他" };
			String[] str3 = { "", "祖父母", "外祖父母", "父亲", "母亲", "兄弟姐妹", "子女" };
			String[] str4 = { "", "无", "有", "不详" };
			
			for (int i = 1; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行
				Family rec = new Family();

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				/** */
				/** 将EXCEL中的第 i 行，第一列的值插入到实例中 */
				HSSFCell cell = row.getCell(0);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setPatientid((long) cell.getNumericCellValue());
				}

				cell = row.getCell(1);

				cell = row.getCell(2);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, str1);
						if (no > -1 && no < 3) {
							rec.setDiabetes(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(3);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, str2);
						if (no > -1 && no < 4) {
							switch (no) {
							case 0:
								rec.setDiabetes1(1);
								break;
							case 1:
								rec.setDiabetes2(1);
								break;
							case 2:
								rec.setDiabetes3(1);
								break;
							case 3:
								rec.setDiabetes4(1);
								break;
							default:
								break;
							}
							
							cell = row.getCell(4);
							if (cell == null) {
							} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
								String tstr2 = cell.getStringCellValue();
								if (tstr2 != null && tstr.length() > 0) {
									String temp="";
									String[] strs=tstr2.split(",");
									for(int j=0;j<strs.length;j++){
										int no2 = getNoByString(tstr2, str3);
										if(no2>0 && no2<7){
											temp+=","+no2;
										}
									}
									if(temp.length()>0){
										rec.setDiabetesrelate1(temp.substring(1));
									}
								}
								
							} else {// 数值
							}
						}
					}
				} else {// 数值
				}
				
				
				HSSFRow row2 = sheet.getRow(++i);// 第2行
				
				while(row2!=null){
					boolean mored=true;
					if(row2!=null){
						cell = row2.getCell(0);
						if(cell != null){							
							String tstr = cell.getStringCellValue();
							if(tstr!=null && tstr.length()>0){
								break;
							}
						}
						cell = row2.getCell(3);
						if(mored){
							String tstr = cell.getStringCellValue();
							if (tstr != null && tstr.length() > 0) {
								int no = getNoByString(tstr, str2);
								if (no > -1 && no < 4) {
									switch (no) {
									case 0:
										rec.setDiabetes1(1);
										break;
									case 1:
										rec.setDiabetes2(1);
										break;
									case 2:
										rec.setDiabetes3(1);
										break;
									case 3:
										rec.setDiabetes4(1);
										break;
									default:
										break;
									}
									
									cell = row2.getCell(4);
									if (cell == null) {
									} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
										String tstr2 = cell.getStringCellValue();
										if (tstr2 != null && tstr.length() > 0) {
											String temp="";
											String[] strs=tstr2.split(",");
											for(int j=0;j<strs.length;j++){
												int no2 = getNoByString(tstr2, str3);
												if(no2>0 && no2<7){
													temp+=","+no2;
												}
											}
											if(temp.length()>0){
												switch (no) {
												case 0:
													rec.setDiabetesrelate2(temp.substring(1));
													break;
												case 1:
													rec.setDiabetesrelate2(temp.substring(1));
													break;
												case 2:
													rec.setDiabetesrelate2(temp.substring(1));
													break;
												case 3:
													rec.setDiabetesrelate2(temp.substring(1));
													break;
												default:
													break;
												}
												
											}
										}
										
									} else {// 数值
									}
								}
							}
						}
					}
					row2= sheet.getRow(++i);// 第2行
				}

				cell = row.getCell(5);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, str4);
						if (no > -1 && no < 4) {
							rec.setLipids(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(6);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {						
						rec.setLipidsname(tstr);
					}
				} else {// 数值
				}

				cell = row.getCell(7);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						String[] strs = tstr.split(",");
						String t = "";
						for (int j = 0; j < strs.length; j++) {
							int no = getNoByString(tstr, str3);
							if (no > 0 && no < 7) {
								t += "," + no;
							}
						}
						rec.setLipidsrelate(t.substring(1));
					}
				} else {// 数值
				}

				cell = row.getCell(8);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, str4);
						if (no > -1 && no < 4) {
							rec.setHighblood(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(9);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						String[] strs = tstr.split(",");
						String t = "";
						for (int j = 0; j < strs.length; j++) {
							int no = getNoByString(tstr, str3);
							if (no > 0 && no < 7) {
								t += "," + no;
							}
						}
						rec.setHighbloodrelate(t.substring(1));
					}
				} else {// 数值
				}

				cell = row.getCell(10);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, str4);
						if (no > -1 && no < 4) {
							rec.setNaoxueguan(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(11);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						String[] strs = tstr.split(",");
						String t = "";
						for (int j = 0; j < strs.length; j++) {
							int no = getNoByString(tstr, str3);
							if (no > 0 && no < 7) {
								t += "," + no;
							}
						}
						rec.setNxgrelate(t.substring(1));
					}
				} else {// 数值
				}

				cell = row.getCell(12);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, str4);
						if (no > -1 && no < 4) {
							rec.setGuanxinbin(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(13);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						String[] strs = tstr.split(",");
						String t = "";
						for (int j = 0; j < strs.length; j++) {
							int no = getNoByString(tstr, str3);
							if (no > 0 && no < 7) {
								t += "," + no;
							}
						}
						rec.setGxbrelate(t.substring(1));
					}
				} else {// 数值
				}

				cell = row.getCell(14);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, str4);
						if (no > -1 && no < 4) {
							rec.setGenetic(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(15);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {						
						rec.setGeneticname(tstr);
					}
				} else {// 数值
				}
				
				cell = row.getCell(16);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						String[] strs = tstr.split(",");
						String t = "";
						for (int j = 0; j < strs.length; j++) {
							int no = getNoByString(tstr, str3);
							if (no > 0 && no < 7) {
								t += "," + no;
							}
						}
						rec.setGeneticrelate(t.substring(1));
					}
				} else {// 数值
				}

				dataService.importFamily(rec);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	private void excelToBear(String filename2) throws Exception {
		// TODO Auto-generated method stub
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();
			if (nol < 2) {
				return;
			}
			String[] yesno = { "", "是", "否" };
			String[] str1 = { "", "无", "有", "不详" };
			for (int i = 1; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行
				Bear rec = new Bear();

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				/** */
				/** 将EXCEL中的第 i 行，第一列的值插入到实例中 */
				HSSFCell cell = row.getCell(0);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setPatientid((long) cell.getNumericCellValue());
				}

				cell = row.getCell(1);

				cell = row.getCell(2);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, yesno);
						if (no > 0 && no < 3) {
							rec.setFenmian(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(3);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setFmcount((int) (double) tdbl);
					}
				}

				cell = row.getCell(4);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, str1);
						if (no > 0 && no < 4) {
							rec.setRensheny(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(5);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setRsycount((int) (double) tdbl);
					}
				}

				cell = row.getCell(6);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, str1);
						if (no > 0 && no < 4) {
							rec.setRenshent(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(7);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setRstcount((int) (double) tdbl);
					}
				}

				cell = row.getCell(8);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, str1);
						if (no > 0 && no < 4) {
							rec.setGongwai(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(9);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setGwcount((int) (double) tdbl);
					}
				}

				cell = row.getCell(10);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, str1);
						if (no > 0 && no < 4) {
							rec.setTaier(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(11);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setTaiercount((int) (double) tdbl);
					}
				}

				cell = row.getCell(12);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, str1);
						if (no > 0 && no < 4) {
							rec.setLiuchan(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(13);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setLccount((int) (double) tdbl);
					}
				}

				dataService.importBear(rec);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	private void excelToPersonal(String filename2) throws Exception {
		// TODO Auto-generated method stub
		FileInputStream fileIn = null;
		try {
			fileIn = new FileInputStream(file);
			HSSFWorkbook wb = new HSSFWorkbook(fileIn);
			HSSFSheet sheet = wb.getSheetAt(0);// 第一个工作表
			int nol = sheet.getPhysicalNumberOfRows();
			if (nol < 3) {
				return;
			}
			String[] yesno = { "否", "是" };
			String[] str1 = { "", "无", "有", "不详" };
			String[] str2 = { "", "大专及以上", "中专", "中学", "小学", "文盲", "不详" };
			String[] str3 = { "", "＜500元", "500－1000元", "1000－2000元",
					"2000－5000元", "5000－10000", "＞10000" };
			String[] str4 = { "", "已婚", "未婚", "再婚", "离异", "丧偶" };
			for (int i = 2; i < nol; i++) {
				HSSFRow row = sheet.getRow(i);// 第2行
				Personal rec = new Personal();

				if (row == null) {
					System.out.println("第" + i + "行已没有数据，");
					break;
				}

				/** */
				/** 将EXCEL中的第 i 行，第一列的值插入到实例中 */
				HSSFCell cell = row.getCell(0);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型

				} else {// 数值
					rec.setPatientid((long) cell.getNumericCellValue());
				}

				cell = row.getCell(1);

				cell = row.getCell(2);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, str2);
						if (no > 0 && no < 7) {
							rec.setEducation(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(3);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, str4);
						if (no > 0 && no < 6) {
							rec.setMarriage(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(4);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, str3);
						if (no > 0 && no < 7) {
							rec.setIncome(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(5);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						rec.setBirthplace(tstr);
					}
				} else {// 数值
				}

				cell = row.getCell(6);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setBirthweight(tdbl);
					}
				}

				cell = row.getCell(7);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						rec.setLiveplace(tstr);
					}
				} else {// 数值
				}

				cell = row.getCell(8);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, str1);
						if (no > 0 && no < 4) {
							rec.setDrugallergy(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(9);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						rec.setDrug(tstr);
					}
				} else {// 数值
				}

				cell = row.getCell(10);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, str1);
						if (no > 0 && no < 4) {
							rec.setFoodallergy(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(11);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						rec.setFood(tstr);
					}
				} else {// 数值
				}

				cell = row.getCell(12);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, yesno);
						if (no > -1 && no < 2) {
							rec.setDrink(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(13);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setDrinkage((int) (double) tdbl);
					}
				}

				String type = "";
				String freq = "";
				String amount = "";
				for (int j = 0; j < 4; j++) {
					cell = row.getCell(14 + j * 3);
					if (cell == null) {
					} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
						String tstr = cell.getStringCellValue();
						if (tstr != null && tstr.length() > 0) {
							int no = getNoByString(tstr, yesno);
							if (no > -1 && no < 2) {
								type+=","+no;
							}							
						}
					} else {// 数值						
					}
					
					cell = row.getCell(15 + j * 3);
					if (cell == null) {
					} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
						String tstr = cell.getStringCellValue();
						if (tstr != null && tstr.length() > 0) {
							freq+=","+tstr;		
						}
					} else {// 数值
						Double tdbl = cell.getNumericCellValue();
						if (tdbl != null) {
							freq+=","+(int) (double) tdbl;
						}
					}
					
					cell = row.getCell(16 + j * 3);
					if (cell == null) {
					} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
						String tstr = cell.getStringCellValue();
						if (tstr != null && tstr.length() > 0) {
							amount+=","+tstr;		
						}
					} else {// 数值
						Double tdbl = cell.getNumericCellValue();
						if (tdbl != null) {
							amount+=","+(int) (double) tdbl;
						}
					}
				}
				if(type.length()>0){
					rec.setDrinktype(type.substring(1));
				}
				
				if(freq.length()>0){
					rec.setDrinkfrequency(freq.substring(1));
				}
				
				if(amount.length()>0){
					rec.setDrinkamount(amount.substring(1));
				}
				
				
				cell = row.getCell(26);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, yesno);
						if (no > -1 && no < 2) {
							rec.setStopdrink(no);
						}
					}
				} else {// 数值
				}
				
				cell = row.getCell(27);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setStopdrinktime(tdbl);
					}
				}
				
				cell = row.getCell(28);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, yesno);
						if (no > -1 && no < 2) {
							rec.setSmoke(no);
						}
					}
				} else {// 数值
				}
				
				cell = row.getCell(29);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setSmokeamount((int)(double)tdbl);
					}
				}
				
				cell = row.getCell(30);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setSmokelast(tdbl);
					}
				}
				
				cell = row.getCell(31);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setSmokeexpo(tdbl);
					}
				}
				
				cell = row.getCell(32);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, yesno);
						if (no > -1 && no < 2) {
							rec.setStopsmoke(no);
						}
					}
				} else {// 数值
				}

				cell = row.getCell(31);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
				} else {// 数值
					Double tdbl = cell.getNumericCellValue();
					if (tdbl != null) {
						rec.setStopsmokelast(tdbl);
					}
				}
				
				cell = row.getCell(32);
				if (cell == null) {
				} else if (cell.getCellType() != 0) {// 如果EXCEL表格中的数据类型为字符串型
					String tstr = cell.getStringCellValue();
					if (tstr != null && tstr.length() > 0) {
						int no = getNoByString(tstr, yesno);
						if (no > -1 && no < 2) {
							rec.setAroundsmoke(no);
						}
					}
				} else {// 数值
				}
				
				dataService.importPersonal(rec);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != fileIn) {
				fileIn.close();
			}
		}
	}

	public OpertResultMsg getOpertMsg() {
		return opertMsg;
	}

	public void setOpertMsg(OpertResultMsg opertMsg) {
		this.opertMsg = opertMsg;
	}

	public int getExtype() {
		return extype;
	}

	public void setExtype(int extype) {
		this.extype = extype;
	}

	public int getImtype() {
		return imtype;
	}

	public void setImtype(int imtype) {
		this.imtype = imtype;
	}

	public String getFilename() {
		return filename;
	}

	public void setFilename(String filename) {
		this.filename = filename;
	}

	public DataService getDataService() {
		return dataService;
	}

	public void setDataService(DataService dataService) {
		this.dataService = dataService;
	}

	public File getFile() {
		return file;
	}

	public void setFile(File file) {
		this.file = file;
	}

	public NutritionService getNutritionService() {
		return nutritionService;
	}

	public void setNutritionService(NutritionService nutritionService) {
		this.nutritionService = nutritionService;
	}
	public SurveyService getSurveyService() {
		return surveyService;
	}

	public void setSurveyService(SurveyService surveyService) {
		this.surveyService = surveyService;
	}

	private int getNoByString(String content, String[] arr) {
		if (arr == null) {
			return -1;
		}
		for (int i = 0; i < arr.length; i++) {
			if (content.equals(arr[i])) {
				return i;
			}
		}
		return -1;
	}
}
